Class AggregationContext.ProductionAggregationContext
java.lang.Object
org.elasticsearch.search.aggregations.support.AggregationContext
org.elasticsearch.search.aggregations.support.AggregationContext.ProductionAggregationContext
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,Releasable
- Enclosing class:
- AggregationContext
public static class AggregationContext.ProductionAggregationContext extends AggregationContext
Implementation of AggregationContext for production usage
that wraps our ubiquitous
SearchExecutionContext
and anything else
specific to aggregations. Unit tests should generally avoid using this
because it requires a huge portion of a real
Elasticsearch node.-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.support.AggregationContext
AggregationContext.ProductionAggregationContext
-
Constructor Summary
Constructors Constructor Description ProductionAggregationContext(SearchExecutionContext context, BigArrays bigArrays, long bytesToPreallocate, java.util.function.Supplier<org.apache.lucene.search.Query> topLevelQuery, AggregationProfiler profiler, MultiBucketConsumerService.MultiBucketConsumer multiBucketConsumer, java.util.function.Supplier<SubSearchContext> subSearchContextBuilder, BitsetFilterCache bitsetFilterCache, int randomSeed, java.util.function.LongSupplier relativeTimeInMillis, java.util.function.Supplier<java.lang.Boolean> isCancelled)
-
Method Summary
Modifier and Type Method Description void
addReleasable(Aggregator aggregator)
Cause this aggregation to be released when the search is finished.BigArrays
bigArrays()
Utility to share and track large arrays.BitsetFilterCache
bitsetFilterCache()
Get the filter cache.CircuitBreaker
breaker()
The circuit breaker used to account for aggs.BucketedSort
buildBucketedSort(SortBuilder<?> sort, int bucketSize, BucketedSort.ExtraData extra)
Build a collector for sorted values specialized for aggregations.protected IndexFieldData<?>
buildFieldData(MappedFieldType ft)
Build field data.org.apache.lucene.search.Query
buildQuery(QueryBuilder builder)
Build a query.java.util.Optional<SortAndFormats>
buildSort(java.util.List<SortBuilder<?>> sortBuilders)
Compile a sort.void
close()
<FactoryType>
FactoryTypecompile(Script script, ScriptContext<FactoryType> scriptContext)
Compile a script.MappedFieldType
getFieldType(java.lang.String path)
Lookup aMappedFieldType
by path.java.util.Collection<MappedFieldType>
getFieldTypes()
Returns the registered mapped field types.org.apache.lucene.analysis.Analyzer
getIndexAnalyzer(java.util.function.Function<java.lang.String,NamedAnalyzer> unindexedFieldAnalyzer)
Return the index-time analyzer for the current indexIndexSettings
getIndexSettings()
The settings for the index against which this search is running.ObjectMapper
getObjectMapper(java.lang.String path)
Find anObjectMapper
.long
getRelativeTimeInMillis()
How many millis have passed since we started the search?ValuesSourceRegistry
getValuesSourceRegistry()
TheValuesSourceRegistry
to resolveAggregator
s and the like.Version
indexVersionCreated()
boolean
isCacheable()
Is this request cacheable? Requests that have non-deterministic queries or scripts aren't cachable.boolean
isCancelled()
Has the search been cancelled?boolean
isFieldMapped(java.lang.String field)
Returns true if the field identified by the provided name is mapped, false otherwiseSearchLookup
lookup()
Fetch the sharedSearchLookup
.MultiBucketConsumerService.MultiBucketConsumer
multiBucketConsumer()
NestedScope
nestedScope()
Access the nested scope.long
nowInMillis()
The time in milliseconds that is shared across all resources involved.Aggregator
profileIfEnabled(Aggregator agg)
Wrap the aggregator for profiling if profiling is enabled.boolean
profiling()
Are we profiling the aggregation?org.apache.lucene.search.Query
query()
The query at the top level of the search in which these aggregations are running.org.apache.lucene.search.IndexSearcher
searcher()
The searcher that will execute this query.int
shardRandomSeed()
Get a deterministic random seed based for this particular shard.SubSearchContext
subSearchContext()
Build a SubSearchContext to power an aggregation fetching top hits.Methods inherited from class org.elasticsearch.search.aggregations.support.AggregationContext
buildFieldContext, buildFieldContext, getUsageService
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ProductionAggregationContext
public ProductionAggregationContext(SearchExecutionContext context, BigArrays bigArrays, long bytesToPreallocate, java.util.function.Supplier<org.apache.lucene.search.Query> topLevelQuery, @Nullable AggregationProfiler profiler, MultiBucketConsumerService.MultiBucketConsumer multiBucketConsumer, java.util.function.Supplier<SubSearchContext> subSearchContextBuilder, BitsetFilterCache bitsetFilterCache, int randomSeed, java.util.function.LongSupplier relativeTimeInMillis, java.util.function.Supplier<java.lang.Boolean> isCancelled)
-
-
Method Details
-
query
public org.apache.lucene.search.Query query()Description copied from class:AggregationContext
The query at the top level of the search in which these aggregations are running.- Specified by:
query
in classAggregationContext
-
profileIfEnabled
Description copied from class:AggregationContext
Wrap the aggregator for profiling if profiling is enabled.- Specified by:
profileIfEnabled
in classAggregationContext
- Throws:
java.io.IOException
-
profiling
public boolean profiling()Description copied from class:AggregationContext
Are we profiling the aggregation?- Specified by:
profiling
in classAggregationContext
-
nowInMillis
public long nowInMillis()Description copied from class:AggregationContext
The time in milliseconds that is shared across all resources involved. Even across shards and nodes.- Specified by:
nowInMillis
in classAggregationContext
-
buildFieldData
Description copied from class:AggregationContext
Build field data.- Specified by:
buildFieldData
in classAggregationContext
-
getFieldType
Description copied from class:AggregationContext
Lookup aMappedFieldType
by path.- Specified by:
getFieldType
in classAggregationContext
-
getFieldTypes
Description copied from class:AggregationContext
Returns the registered mapped field types.- Specified by:
getFieldTypes
in classAggregationContext
-
isFieldMapped
public boolean isFieldMapped(java.lang.String field)Description copied from class:AggregationContext
Returns true if the field identified by the provided name is mapped, false otherwise- Specified by:
isFieldMapped
in classAggregationContext
-
compile
Description copied from class:AggregationContext
Compile a script.- Specified by:
compile
in classAggregationContext
-
lookup
Description copied from class:AggregationContext
Fetch the sharedSearchLookup
.- Specified by:
lookup
in classAggregationContext
-
getValuesSourceRegistry
Description copied from class:AggregationContext
TheValuesSourceRegistry
to resolveAggregator
s and the like.- Specified by:
getValuesSourceRegistry
in classAggregationContext
-
bigArrays
Description copied from class:AggregationContext
Utility to share and track large arrays.- Specified by:
bigArrays
in classAggregationContext
-
searcher
public org.apache.lucene.search.IndexSearcher searcher()Description copied from class:AggregationContext
The searcher that will execute this query.- Specified by:
searcher
in classAggregationContext
-
buildQuery
Description copied from class:AggregationContext
Build a query.- Specified by:
buildQuery
in classAggregationContext
- Throws:
java.io.IOException
-
getIndexSettings
Description copied from class:AggregationContext
The settings for the index against which this search is running.- Specified by:
getIndexSettings
in classAggregationContext
-
buildSort
public java.util.Optional<SortAndFormats> buildSort(java.util.List<SortBuilder<?>> sortBuilders) throws java.io.IOExceptionDescription copied from class:AggregationContext
Compile a sort.- Specified by:
buildSort
in classAggregationContext
- Throws:
java.io.IOException
-
getObjectMapper
Description copied from class:AggregationContext
Find anObjectMapper
.- Specified by:
getObjectMapper
in classAggregationContext
-
nestedScope
Description copied from class:AggregationContext
Access the nested scope. Stay away from this unless you are dealing with nested.- Specified by:
nestedScope
in classAggregationContext
-
subSearchContext
Description copied from class:AggregationContext
Build a SubSearchContext to power an aggregation fetching top hits. Try to avoid using this because it pulls in a ton of dependencies.- Specified by:
subSearchContext
in classAggregationContext
-
addReleasable
Description copied from class:AggregationContext
Cause this aggregation to be released when the search is finished.- Specified by:
addReleasable
in classAggregationContext
-
multiBucketConsumer
- Specified by:
multiBucketConsumer
in classAggregationContext
-
bitsetFilterCache
Description copied from class:AggregationContext
Get the filter cache.- Specified by:
bitsetFilterCache
in classAggregationContext
-
buildBucketedSort
public BucketedSort buildBucketedSort(SortBuilder<?> sort, int bucketSize, BucketedSort.ExtraData extra) throws java.io.IOExceptionDescription copied from class:AggregationContext
Build a collector for sorted values specialized for aggregations.- Specified by:
buildBucketedSort
in classAggregationContext
- Throws:
java.io.IOException
-
shardRandomSeed
public int shardRandomSeed()Description copied from class:AggregationContext
Get a deterministic random seed based for this particular shard.- Specified by:
shardRandomSeed
in classAggregationContext
-
getRelativeTimeInMillis
public long getRelativeTimeInMillis()Description copied from class:AggregationContext
How many millis have passed since we started the search?- Specified by:
getRelativeTimeInMillis
in classAggregationContext
-
isCancelled
public boolean isCancelled()Description copied from class:AggregationContext
Has the search been cancelled?This'll require a
volatile
read.- Specified by:
isCancelled
in classAggregationContext
-
breaker
Description copied from class:AggregationContext
The circuit breaker used to account for aggs.- Specified by:
breaker
in classAggregationContext
-
getIndexAnalyzer
public org.apache.lucene.analysis.Analyzer getIndexAnalyzer(java.util.function.Function<java.lang.String,NamedAnalyzer> unindexedFieldAnalyzer)Description copied from class:AggregationContext
Return the index-time analyzer for the current index- Specified by:
getIndexAnalyzer
in classAggregationContext
- Parameters:
unindexedFieldAnalyzer
- a function that builds an analyzer for unindexed fields
-
indexVersionCreated
- Specified by:
indexVersionCreated
in classAggregationContext
-
isCacheable
public boolean isCacheable()Description copied from class:AggregationContext
Is this request cacheable? Requests that have non-deterministic queries or scripts aren't cachable.- Specified by:
isCacheable
in classAggregationContext
-
close
public void close()
-