Class ValuesSourceConfig
java.lang.Object
org.elasticsearch.search.aggregations.support.ValuesSourceConfig
public class ValuesSourceConfig
extends java.lang.Object
A configuration that tells aggregations how to retrieve data from the index
in order to run a specific aggregation.
-
Constructor Summary
Constructors Constructor Description ValuesSourceConfig(ValuesSourceType valuesSourceType, MappedFieldType fieldType, boolean unmapped, AggregationScript.LeafFactory script, ValueType scriptValueType, QueryShardContext queryShardContext) -
Method Summary
Modifier and Type Method Description FieldContextfieldContext()DocValueFormatformat()java.lang.Objectmissing()static ValuesSourceConfigresolve(QueryShardContext context, ValueType userValueTypeHint, java.lang.String field, Script script, java.lang.Object missing, java.time.ZoneId timeZone, java.lang.String format, ValuesSourceType defaultValueSourceType, java.lang.String aggregationName)Given the query context and other information, decide on the inputValuesSourcefor this aggretation run, and construct a newValuesSourceConfigbased on thatValuesSourceTypestatic ValuesSourceConfigresolveFieldOnly(MappedFieldType fieldType, QueryShardContext queryShardContext)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 ValuesSourceConfigresolveUnmapped(ValuesSourceType valuesSourceType, QueryShardContext queryShardContext)Convenience method for creating unmapped configsstatic ValuesSourceConfigresolveUnregistered(QueryShardContext context, ValueType userValueTypeHint, java.lang.String field, Script script, java.lang.Object missing, java.time.ZoneId timeZone, java.lang.String format, ValuesSourceType defaultValueSourceType)AKA legacy resolve.AggregationScript.LeafFactoryscript()ValueTypescriptValueType()java.time.ZoneIdtimezone()ValuesSourcetoValuesSource()Transform theValuesSourceTypewe selected in resolve into the specificValuesSourceinstance to use for this shardbooleanunmapped()booleanvalid()ValuesSourceTypevalueSourceType()
-
Constructor Details
-
ValuesSourceConfig
public ValuesSourceConfig(ValuesSourceType valuesSourceType, MappedFieldType fieldType, boolean unmapped, AggregationScript.LeafFactory script, ValueType scriptValueType, QueryShardContext queryShardContext)
-
-
Method Details
-
resolve
public static ValuesSourceConfig resolve(QueryShardContext context, ValueType userValueTypeHint, java.lang.String field, Script script, java.lang.Object missing, java.time.ZoneId timeZone, java.lang.String format, ValuesSourceType defaultValueSourceType, java.lang.String aggregationName)Given the query context and other information, decide on the inputValuesSourcefor this aggretation run, and construct a newValuesSourceConfigbased 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-aggregationValuesSourceof last resort.aggregationName- - Name of the aggregation, generally from the aggregation builder. This is used as a lookup key in theValuesSourceRegistry- Returns:
- - An initialized
ValuesSourceConfigthat will yield the appropriateValuesSourceType
-
resolveUnregistered
public static ValuesSourceConfig resolveUnregistered(QueryShardContext context, ValueType userValueTypeHint, java.lang.String field, Script script, java.lang.Object missing, java.time.ZoneId timeZone, java.lang.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 fromValuesSourceAggregationBuildershould not use this method, preferringresolve(org.elasticsearch.index.query.QueryShardContext, 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, java.lang.String)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-aggregationValuesSourceof last resort.- Returns:
- - An initialized
ValuesSourceConfigthat will yield the appropriateValuesSourceType
-
resolveFieldOnly
public static ValuesSourceConfig resolveFieldOnly(MappedFieldType fieldType, QueryShardContext queryShardContext)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, QueryShardContext queryShardContext)Convenience method for creating unmapped configs -
valueSourceType
-
fieldContext
-
script
-
unmapped
public boolean unmapped() -
valid
public boolean valid() -
scriptValueType
-
missing
public java.lang.Object missing() -
timezone
public java.time.ZoneId timezone() -
format
-
toValuesSource
Transform theValuesSourceTypewe selected in resolve into the specificValuesSourceinstance to use for this shard- Returns:
- - A
ValuesSourceready to be read from by an aggregator
-