Module org.elasticsearch.xcore
Class DatafeedConfig
java.lang.Object
org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig
- All Implemented Interfaces:
Closeable,AutoCloseable,Diffable<DatafeedConfig>,SimpleDiffable<DatafeedConfig>,Writeable,Releasable,ToXContent,ToXContentObject
public class DatafeedConfig
extends Object
implements SimpleDiffable<DatafeedConfig>, ToXContentObject, Releasable
Datafeed configuration options. Describes where to proactively pull input
data from.
If a value has not been set it will be null. Object wrappers are
used around integral types and booleans so they can take null
values.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.elasticsearch.cluster.SimpleDiffable
SimpleDiffable.CompleteDiff<T extends Diffable<T>>Nested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final TransportVersionstatic final intstatic final intstatic final ParseFieldstatic final StringThe field name used to specify document counts in Elasticsearch aggregationsstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ObjectParser<DatafeedConfig.Builder, Void> static final ParseFieldstatic final ParseFieldstatic final Stringstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ObjectParser<DatafeedConfig.Builder, Void> static final StringFields inherited from interface org.elasticsearch.cluster.SimpleDiffable
EMPTYFields inherited from interface org.elasticsearch.xcontent.ToXContent
EMPTY, EMPTY_PARAMS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanvoidclose()Releases the underlyingPersistedCloudCredentialand itsSecureString, if present.defaultFrequency(TimeValue bucketSpan, NamedXContentRegistry xContentRegistry) Calculates a sensible default frequency for a given bucket span.static StringdocumentId(String datafeedId) The name of datafeed configuration document name from the datafeed ID.booleanThe lists of indices and types are compared for equality but they are not sorted first so this test could fail simply because the indices and types lists are in different orders.getAggDeprecations(NamedXContentRegistry namedXContentRegistry) Calls the parser and returns any gathered deprecationsorg.elasticsearch.xpack.core.ml.datafeed.AggProviderlonggetHistogramIntervalMillis(NamedXContentRegistry namedXContentRegistry) Returns the histogram's interval as epoch millis.getId()getJobId()getParsedAggregations(NamedXContentRegistry namedXContentRegistry) Fully parses the semi-parsedMap<String, Object>aggregationsgetParsedQuery(NamedXContentRegistry namedXContentRegistry) Get the fully parsed query from the semi-parsed storedMap<String, Object>getQuery()getQueryDeprecations(NamedXContentRegistry namedXContentRegistry) Calls the parser and returns any gathered deprecationsbooleanbooleanhasCompositeAgg(NamedXContentRegistry namedXContentRegistry) Indicates if the datafeed is using composite aggs.inthashCode()static booleanisCPSAllowed(CrossProjectModeDecider crossProjectModeDecider) Returns whether ML cross-project search (CPS) is allowed for datafeeds in the current environment.static ElasticsearchStatusExceptionsetHeaders(Map<String, String> headers) toString()toXContent(XContentBuilder builder, ToXContent.Params params) static voidvalidateAggregations(AggregatorFactories.Builder aggregations) validateNoCrossProjectWhenCrossProjectIsDisabled(CrossProjectModeDecider crossProjectModeDecider, ActionRequestValidationException validationException) validateNoCrossProjectWhenCrossProjectIsDisabled(CrossProjectModeDecider crossProjectModeDecider, ElasticsearchException validationException) static DatafeedConfigwithCrossProjectModeIfEnabled(DatafeedConfig datafeed, CrossProjectModeDecider crossProjectModeDecider) voidwriteTo(StreamOutput out) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.cluster.SimpleDiffable
diffMethods inherited from interface org.elasticsearch.xcontent.ToXContentObject
isFragment
-
Field Details
-
DEFAULT_SCROLL_SIZE
public static final int DEFAULT_SCROLL_SIZE- See Also:
-
DEFAULT_AGGREGATION_CHUNKING_BUCKETS
public static final int DEFAULT_AGGREGATION_CHUNKING_BUCKETS- See Also:
-
RESULTS_FIELD
-
TYPE
- See Also:
-
DOC_COUNT
The field name used to specify document counts in Elasticsearch aggregations- See Also:
-
DATAFEED_CLOUD_INTERNAL_CREDENTIAL
-
PROJECT_ROUTING_REQUIRES_CPS_MESSAGE
- See Also:
-
JOB_ID
-
ID
-
CONFIG_TYPE
-
QUERY_DELAY
-
FREQUENCY
-
INDEXES
-
INDICES
-
QUERY
-
SCROLL_SIZE
-
AGGREGATIONS
-
AGGS
-
SCRIPT_FIELDS
-
CHUNKING_CONFIG
-
HEADERS
-
DELAYED_DATA_CHECK_CONFIG
-
MAX_EMPTY_SEARCHES
-
INDICES_OPTIONS
-
PROJECT_ROUTING
-
CLOUD_INTERNAL_CREDENTIAL
-
LENIENT_PARSER
-
STRICT_PARSER
-
-
Constructor Details
-
DatafeedConfig
- Throws:
IOException
-
-
Method Details
-
isCPSAllowed
Returns whether ML cross-project search (CPS) is allowed for datafeeds in the current environment.Both the cluster-level
serverless.cross_project.enabledsetting and the ML CPS feature flag (CloudCredentialsExtension.ML_CROSS_PROJECT) must be enabled. Without this combined gate, every datafeed start on a CPS-enabled cluster — including ones targeting only local indices — would be promoted to cross-project mode, which violates the "off by default on main" contract of the ML CPS scaffolding. -
projectRoutingRequiresCpsException
-
validateAggregations
-
validateNoCrossProjectWhenCrossProjectIsDisabled
public ElasticsearchException validateNoCrossProjectWhenCrossProjectIsDisabled(CrossProjectModeDecider crossProjectModeDecider, ElasticsearchException validationException) -
withCrossProjectModeIfEnabled
public static DatafeedConfig withCrossProjectModeIfEnabled(DatafeedConfig datafeed, CrossProjectModeDecider crossProjectModeDecider) -
documentId
The name of datafeed configuration document name from the datafeed ID.- Parameters:
datafeedId- The datafeed ID- Returns:
- The ID of document the datafeed config is persisted in
-
validateNoCrossProjectWhenCrossProjectIsDisabled
public ActionRequestValidationException validateNoCrossProjectWhenCrossProjectIsDisabled(CrossProjectModeDecider crossProjectModeDecider, ActionRequestValidationException validationException) -
getId
-
getJobId
-
getConfigType
-
getQueryDelay
-
getFrequency
-
getIndices
-
getScrollSize
-
minRequiredTransportVersion
-
getParsedQuery
Get the fully parsed query from the semi-parsed storedMap<String, Object>- Parameters:
namedXContentRegistry- XContent registry to transform the lazily parsed query- Returns:
- Fully parsed query
-
getQueryDeprecations
Calls the parser and returns any gathered deprecations- Parameters:
namedXContentRegistry- XContent registry to transform the lazily parsed query- Returns:
- The deprecations from parsing the query
-
getQuery
-
getParsedAggregations
public AggregatorFactories.Builder getParsedAggregations(NamedXContentRegistry namedXContentRegistry) Fully parses the semi-parsedMap<String, Object>aggregations- Parameters:
namedXContentRegistry- XContent registry to transform the lazily parsed aggregations- Returns:
- The fully parsed aggregations
-
getAggDeprecations
Calls the parser and returns any gathered deprecations- Parameters:
namedXContentRegistry- XContent registry to transform the lazily parsed aggregations- Returns:
- The deprecations from parsing the aggregations
-
getAggregations
-
getHistogramIntervalMillis
Returns the histogram's interval as epoch millis.- Parameters:
namedXContentRegistry- XContent registry to transform the lazily parsed aggregations
-
hasCompositeAgg
Indicates if the datafeed is using composite aggs.- Parameters:
namedXContentRegistry- XContent registry to transform the lazily parsed aggregations- Returns:
- If the datafeed utilizes composite aggs or not
-
hasAggregations
public boolean hasAggregations()- Returns:
truewhen there are non-empty aggregations,falseotherwise
-
aggsRewritten
public boolean aggsRewritten() -
getAggProvider
public org.elasticsearch.xpack.core.ml.datafeed.AggProvider getAggProvider() -
getScriptFields
-
getChunkingConfig
-
getHeaders
-
setHeaders
-
getDelayedDataCheckConfig
-
getMaxEmptySearches
-
getIndicesOptions
-
getRuntimeMappings
-
getProjectRouting
-
getCloudInternalCredential
-
close
public void close()Releases the underlyingPersistedCloudCredentialand itsSecureString, if present. Idempotent: safe to call more than once.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceReleasable
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toXContent
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
toXContentin interfaceToXContent- Throws:
IOException
-
equals
The lists of indices and types are compared for equality but they are not sorted first so this test could fail simply because the indices and types lists are in different orders. -
hashCode
public int hashCode() -
toString
-
defaultFrequency
Calculates a sensible default frequency for a given bucket span.The default depends on the bucket span:
- <= 2 mins -> 1 min
- <= 20 mins -> bucket span / 2
- <= 12 hours -> 10 mins
- > 12 hours -> 1 hour
- Parameters:
bucketSpan- the bucket span- Returns:
- the default frequency
-