Package org.opensearch.search.aggregations.support


package org.opensearch.search.aggregations.support

This package holds shared code for the aggregations framework, especially around dealing with values.

Key Classes

ValuesSource and its subclasses

These are thin wrappers which provide a unified interface to different ways of getting input data (e.g. DocValues from Lucene, or script output). A class hierarchy defines the type of values returned by the source. The top level sub-classes define type-specific behavior, such as ValuesSource.Numeric.isFloatingPoint(). Second level subclasses are then specialized based on where they read values from, e.g. script or field cases. There are also adapter classes like org.opensearch.search.aggregations.bucket.geogrid.CellIdSource which do run-time conversion from one type to another, often dependent on a user specified parameter (precision in that case).

ValuesSourceRegistry

ValuesSourceRegistry stores the mappings for what types are supported by what aggregations. It is configured at startup, when SearchModule is configuring aggregations. It shouldn't be necessary to access the registry in most cases, but you can get a read copy from QueryShardContext.getValuesSourceRegistry() if necessary.

ValuesSourceType

ValuesSourceTypes are the quantum of support in the aggregations framework, and provide a common language between fields and aggregations. Fields which support aggregation set a ValuesSourceType on their IndexFieldData implementations, and aggregations register what types they support via one of the ValuesSourceRegistry.Builder.register(org.opensearch.search.aggregations.support.ValuesSourceRegistry.RegistryKey<T>, org.opensearch.search.aggregations.support.ValuesSourceType, T, boolean) methods. The VaulesSourceType itself holds information on how to with values of that type, including methods for creating ValuesSource instances and DocValueFormat instances.

ValuesSourceConfig

There are two things going on in ValuesSourceConfig. First, there is a collection of static factory methods to build valid configs for different situations. ValuesSourceAggregationBuilder.resolveConfig(org.opensearch.index.query.QueryShardContext) has a good default for what to call here and generally aggregations shouldn't need to deviate from that.

Once properly constructed, the ValuesSourceConfig provides access to the ValuesSource instance, as well as related information like the formatter. Aggregations are free to use this information as needed, such as Max and Min which inspect the field context to see if they can apply an optimization.

Classes we are trying to phase out

ValueType

This class is primarily used for parsing user type hints, and is deprecated for new use. Work is ongoing to remove it from existing code.