Class ValuesSourceConfig
java.lang.Object
org.elasticsearch.search.aggregations.support.ValuesSourceConfig
A configuration that tells aggregations how to retrieve data from the index
in order to run a specific aggregation.
-
Constructor Summary
ConstructorDescriptionValuesSourceConfig(ValuesSourceType valuesSourceType, FieldContext fieldContext, boolean unmapped, AggregationScript.LeafFactory script, ValueType scriptValueType, Object missing, ZoneId timeZone, DocValueFormat format, AggregationContext context)
-
Method Summary
Modifier and TypeMethodDescriptionboolean
DoValuesSource
s built by this config line up with the search index of the underlying field? This'll only return true if the fields is searchable and there aren't missing values or a script to confuse the ordering.Convenience method for looking up the mapped field type backing this values source, if it exists.format()
Returns a human readable description of this values source, for use in error messages and similar.This method is used when an aggregation can optimize by using the indexed data instead of the doc values.boolean
Check if this values source supports using global and segment ordinals.boolean
Returns true if the values source configured by this object can yield values.missing()
static ValuesSourceConfig
resolve(AggregationContext context, ValueType userValueTypeHint, String field, Script script, Object missing, ZoneId timeZone, String format, ValuesSourceType defaultValueSourceType)
Given the query context and other information, decide on the inputValuesSource
for this aggretation run, and construct a newValuesSourceConfig
based on thatValuesSourceType
static ValuesSourceConfig
resolveFieldOnly(MappedFieldType fieldType, AggregationContext context)
Special case factory method, intended to be used by aggregations which have some specialized logic for figuring out what field they are operating on, for example Parent and Child join aggregations, which use the join relation to find the field they are reading from rather than a user specified field.static ValuesSourceConfig
resolveUnmapped(ValuesSourceType valuesSourceType, AggregationContext context)
Convenience method for creating unmapped configsstatic ValuesSourceConfig
resolveUnregistered(AggregationContext context, ValueType userValueTypeHint, String field, Script script, Object missing, ZoneId timeZone, String format, ValuesSourceType defaultValueSourceType)
AKA legacy resolve.Build a function prepares rounding values to be called many times.script()
timezone()
boolean
valid()
-
Constructor Details
-
ValuesSourceConfig
public ValuesSourceConfig(ValuesSourceType valuesSourceType, FieldContext fieldContext, boolean unmapped, AggregationScript.LeafFactory script, ValueType scriptValueType, Object missing, ZoneId timeZone, DocValueFormat format, AggregationContext context)
-
-
Method Details
-
resolve
public static ValuesSourceConfig resolve(AggregationContext context, ValueType userValueTypeHint, String field, Script script, Object missing, ZoneId timeZone, String format, ValuesSourceType defaultValueSourceType)Given the query context and other information, decide on the inputValuesSource
for this aggretation run, and construct a newValuesSourceConfig
based on thatValuesSourceType
- Parameters:
context
- - the query contextuserValueTypeHint
- - User specified value type; used for missing values and scriptsfield
- - The field being aggregated over. At least one of field and script must not be nullscript
- - The script the user specified. At least one of field and script must not be nullmissing
- - A user specified value to apply when the field is missing. Should be of type userValueTypeHinttimeZone
- - Used to generate a format for datesformat
- - The format string to apply to this field. Confusingly, this is used for input parsing as well as output formatting See https://github.com/elastic/elasticsearch/issues/47469defaultValueSourceType
- - per-aggregationValuesSource
of last resort.- Returns:
- - An initialized
ValuesSourceConfig
that will yield the appropriateValuesSourceType
-
resolveUnregistered
public static ValuesSourceConfig resolveUnregistered(AggregationContext context, ValueType userValueTypeHint, String field, Script script, Object missing, ZoneId timeZone, String format, ValuesSourceType defaultValueSourceType)AKA legacy resolve. This method should be called by aggregations not supported by theValuesSourceRegistry
, to use the pre-registry logic to decide on theValuesSourceType
. New aggregations which extend fromValuesSourceAggregationBuilder
should not use this method, preferringresolve(org.elasticsearch.search.aggregations.support.AggregationContext, org.elasticsearch.search.aggregations.support.ValueType, java.lang.String, org.elasticsearch.script.Script, java.lang.Object, java.time.ZoneId, java.lang.String, org.elasticsearch.search.aggregations.support.ValuesSourceType)
instead.- Parameters:
context
- - the query contextuserValueTypeHint
- - User specified value type; used for missing values and scriptsfield
- - The field being aggregated over. At least one of field and script must not be nullscript
- - The script the user specified. At least one of field and script must not be nullmissing
- - A user specified value to apply when the field is missing. Should be of type userValueTypeHinttimeZone
- - Used to generate a format for datesformat
- - The format string to apply to this field. Confusingly, this is used for input parsing as well as output formatting See https://github.com/elastic/elasticsearch/issues/47469defaultValueSourceType
- - per-aggregationValuesSource
of last resort.- Returns:
- - An initialized
ValuesSourceConfig
that will yield the appropriateValuesSourceType
-
resolveFieldOnly
public static ValuesSourceConfig resolveFieldOnly(MappedFieldType fieldType, AggregationContext context)Special case factory method, intended to be used by aggregations which have some specialized logic for figuring out what field they are operating on, for example Parent and Child join aggregations, which use the join relation to find the field they are reading from rather than a user specified field. -
resolveUnmapped
public static ValuesSourceConfig resolveUnmapped(ValuesSourceType valuesSourceType, AggregationContext context)Convenience method for creating unmapped configs -
valueSourceType
-
fieldContext
-
fieldType
Convenience method for looking up the mapped field type backing this values source, if it exists. -
script
-
hasValues
public boolean hasValues()Returns true if the values source configured by this object can yield values. We might not be able to yield values if, for example, the specified field does not exist on this index. -
valid
public boolean valid() -
scriptValueType
-
missing
-
timezone
-
format
-
getValuesSource
-
roundingPreparer
Build a function prepares rounding values to be called many times.This returns a Function because auto date histogram will need to call it many times over the course of running the aggregation.
- Throws:
IOException
-
hasOrdinals
public boolean hasOrdinals()Check if this values source supports using global and segment ordinals. -
getPointReaderOrNull
This method is used when an aggregation can optimize by using the indexed data instead of the doc values. We check to see if the indexed data will match the values source output (meaning there isn't a script or a missing value, since both could modify the value at read time). If the settings allow for it, we then ask theValuesSourceType
to build the actual point reader based on the field type. This allows for a point of extensibility in plugins.- Returns:
- null if we cannot apply the optimization, otherwise the point reader function.
-
alignesWithSearchIndex
public boolean alignesWithSearchIndex()DoValuesSource
s built by this config line up with the search index of the underlying field? This'll only return true if the fields is searchable and there aren't missing values or a script to confuse the ordering. -
getDescription
Returns a human readable description of this values source, for use in error messages and similar.
-