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 FieldContext
fieldContext()
DocValueFormat
format()
java.lang.Object
missing()
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 inputValuesSource
for this aggretation run, and construct a newValuesSourceConfig
based on thatValuesSourceType
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.static ValuesSourceConfig
resolveUnmapped(ValuesSourceType valuesSourceType, QueryShardContext queryShardContext)
Convenience method for creating unmapped configsstatic 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.AggregationScript.LeafFactory
script()
ValueType
scriptValueType()
java.time.ZoneId
timezone()
ValuesSource
toValuesSource()
Transform theValuesSourceType
we selected in resolve into the specificValuesSource
instance to use for this shardboolean
unmapped()
boolean
valid()
ValuesSourceType
valueSourceType()
-
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 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.aggregationName
- - Name of the aggregation, generally from the aggregation builder. This is used as a lookup key in theValuesSourceRegistry
- Returns:
- - An initialized
ValuesSourceConfig
that 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 fromValuesSourceAggregationBuilder
should 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-aggregationValuesSource
of last resort.- Returns:
- - An initialized
ValuesSourceConfig
that 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 theValuesSourceType
we selected in resolve into the specificValuesSource
instance to use for this shard- Returns:
- - A
ValuesSource
ready to be read from by an aggregator
-