java.lang.Object
org.elasticsearch.xpack.core.ml.datafeed.DatafeedConfig
All Implemented Interfaces:
Diffable<DatafeedConfig>, SimpleDiffable<DatafeedConfig>, Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentObject

public class DatafeedConfig extends Object implements SimpleDiffable<DatafeedConfig>, org.elasticsearch.xcontent.ToXContentObject
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.

  • 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

      public static final org.elasticsearch.xcontent.ParseField RESULTS_FIELD
    • TYPE

      public static final String TYPE
      See Also:
    • DOC_COUNT

      public static final String DOC_COUNT
      The field name used to specify document counts in Elasticsearch aggregations
      See Also:
    • JOB_ID

      public static final org.elasticsearch.xcontent.ParseField JOB_ID
    • ID

      public static final org.elasticsearch.xcontent.ParseField ID
    • CONFIG_TYPE

      public static final org.elasticsearch.xcontent.ParseField CONFIG_TYPE
    • QUERY_DELAY

      public static final org.elasticsearch.xcontent.ParseField QUERY_DELAY
    • FREQUENCY

      public static final org.elasticsearch.xcontent.ParseField FREQUENCY
    • INDEXES

      public static final org.elasticsearch.xcontent.ParseField INDEXES
    • INDICES

      public static final org.elasticsearch.xcontent.ParseField INDICES
    • QUERY

      public static final org.elasticsearch.xcontent.ParseField QUERY
    • SCROLL_SIZE

      public static final org.elasticsearch.xcontent.ParseField SCROLL_SIZE
    • AGGREGATIONS

      public static final org.elasticsearch.xcontent.ParseField AGGREGATIONS
    • AGGS

      public static final org.elasticsearch.xcontent.ParseField AGGS
    • SCRIPT_FIELDS

      public static final org.elasticsearch.xcontent.ParseField SCRIPT_FIELDS
    • CHUNKING_CONFIG

      public static final org.elasticsearch.xcontent.ParseField CHUNKING_CONFIG
    • HEADERS

      public static final org.elasticsearch.xcontent.ParseField HEADERS
    • DELAYED_DATA_CHECK_CONFIG

      public static final org.elasticsearch.xcontent.ParseField DELAYED_DATA_CHECK_CONFIG
    • MAX_EMPTY_SEARCHES

      public static final org.elasticsearch.xcontent.ParseField MAX_EMPTY_SEARCHES
    • INDICES_OPTIONS

      public static final org.elasticsearch.xcontent.ParseField INDICES_OPTIONS
    • LENIENT_PARSER

      public static final org.elasticsearch.xcontent.ObjectParser<DatafeedConfig.Builder,Void> LENIENT_PARSER
    • STRICT_PARSER

      public static final org.elasticsearch.xcontent.ObjectParser<DatafeedConfig.Builder,Void> STRICT_PARSER
  • Constructor Details

  • Method Details

    • validateAggregations

      public static void validateAggregations(AggregatorFactories.Builder aggregations)
    • documentId

      public static String documentId(String datafeedId)
      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
    • getId

      public String getId()
    • getJobId

      public String getJobId()
    • getConfigType

      public String getConfigType()
    • getQueryDelay

      public org.elasticsearch.core.TimeValue getQueryDelay()
    • getFrequency

      public org.elasticsearch.core.TimeValue getFrequency()
    • getIndices

      public List<String> getIndices()
    • getScrollSize

      public Integer getScrollSize()
    • minRequiredTransportVersion

      public Optional<org.elasticsearch.core.Tuple<TransportVersion,String>> minRequiredTransportVersion()
    • getParsedQuery

      public QueryBuilder getParsedQuery(org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry)
      Get the fully parsed query from the semi-parsed stored Map<String, Object>
      Parameters:
      namedXContentRegistry - XContent registry to transform the lazily parsed query
      Returns:
      Fully parsed query
    • getQueryDeprecations

      public List<String> getQueryDeprecations(org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry)
      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

      public Map<String,Object> getQuery()
    • getParsedAggregations

      public AggregatorFactories.Builder getParsedAggregations(org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry)
      Fully parses the semi-parsed Map<String, Object> aggregations
      Parameters:
      namedXContentRegistry - XContent registry to transform the lazily parsed aggregations
      Returns:
      The fully parsed aggregations
    • getAggDeprecations

      public List<String> getAggDeprecations(org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry)
      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

      public Map<String,Object> getAggregations()
    • getHistogramIntervalMillis

      public long getHistogramIntervalMillis(org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry)
      Returns the histogram's interval as epoch millis.
      Parameters:
      namedXContentRegistry - XContent registry to transform the lazily parsed aggregations
    • hasCompositeAgg

      public boolean hasCompositeAgg(org.elasticsearch.xcontent.NamedXContentRegistry namedXContentRegistry)
      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:
      true when there are non-empty aggregations, false otherwise
    • aggsRewritten

      public boolean aggsRewritten()
    • getAggProvider

      public org.elasticsearch.xpack.core.ml.datafeed.AggProvider getAggProvider()
    • getScriptFields

      public List<SearchSourceBuilder.ScriptField> getScriptFields()
    • getChunkingConfig

      public ChunkingConfig getChunkingConfig()
    • getHeaders

      public Map<String,String> getHeaders()
    • getDelayedDataCheckConfig

      public DelayedDataCheckConfig getDelayedDataCheckConfig()
    • getMaxEmptySearches

      public Integer getMaxEmptySearches()
    • getIndicesOptions

      public IndicesOptions getIndicesOptions()
    • getRuntimeMappings

      public Map<String,Object> getRuntimeMappings()
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object other)
      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.
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • defaultFrequency

      public org.elasticsearch.core.TimeValue defaultFrequency(org.elasticsearch.core.TimeValue bucketSpan, org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry)
      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
      If the datafeed has aggregations, the default frequency is the closest multiple of the histogram interval based on the rules above.
      Parameters:
      bucketSpan - the bucket span
      Returns:
      the default frequency