Class AggregationContext.ProductionAggregationContext
java.lang.Object
org.elasticsearch.search.aggregations.support.AggregationContext
org.elasticsearch.search.aggregations.support.AggregationContext.ProductionAggregationContext
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.elasticsearch.core.Releasable
- Enclosing class:
- 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
ConstructorDescriptionProductionAggregationContext(SearchExecutionContext context, BigArrays bigArrays, long bytesToPreallocate, Supplier<org.apache.lucene.search.Query> topLevelQuery, AggregationProfiler profiler, MultiBucketConsumerService.MultiBucketConsumer multiBucketConsumer, Supplier<SubSearchContext> subSearchContextBuilder, BitsetFilterCache bitsetFilterCache, int randomSeed, LongSupplier relativeTimeInMillis, Supplier<Boolean> isCancelled, Function<org.apache.lucene.search.Query,org.apache.lucene.search.Query> filterQuery, boolean enableRewriteToFilterByFilter)
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addReleasable(Aggregator aggregator)
Cause this aggregation to be released when the search is finished.Utility to share and track large arrays.Get the filter cache.breaker()
The circuit breaker used to account for aggs.buildBucketedSort(SortBuilder<?> sort, int bucketSize, BucketedSort.ExtraData extra)
Build a collector for sorted values specialized for aggregations.protected IndexFieldData<?>
Build field data.org.apache.lucene.search.Query
buildQuery(QueryBuilder builder)
Build a query.buildSort(List<SortBuilder<?>> sortBuilders)
Compile a sort.void
close()
<FactoryType>
FactoryTypecompile(Script script, ScriptContext<FactoryType> scriptContext)
Compile a script.boolean
Are aggregations allowed to try to rewrite themselves intoFilterByFilterAggregator
aggregations? Often FilterByFilterAggregator is faster to execute, but it isn't always.org.apache.lucene.search.Query
filterQuery(org.apache.lucene.search.Query query)
Add filters from slice or filtered aliases.getFieldType(String path)
Lookup aMappedFieldType
by path.org.apache.lucene.analysis.Analyzer
getIndexAnalyzer(Function<String,NamedAnalyzer> unindexedFieldAnalyzer)
Return the index-time analyzer for the current indexThe settings for the index against which this search is running.getMatchingFieldNames(String pattern)
Returns a set of field names that match a regex-like pattern All field names in the returned set are guaranteed to resolve to a fieldgetObjectMapper(String path)
Find anObjectMapper
.long
How many millis have passed since we started the search?TheValuesSourceRegistry
to resolveAggregator
s and the like.boolean
Is this request cacheable? Requests that have non-deterministic queries or scripts aren't cachable.boolean
Has the search been cancelled?boolean
isFieldMapped(String field)
Returns true if the field identified by the provided name is mapped, false otherwiselookup()
Fetch the sharedSearchLookup
.Access the nested scope.long
The time in milliseconds that is shared across all resources involved.Wrap the aggregator for profiling if profiling is enabled.boolean
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
Get a deterministic random seed based for this particular shard.Build a SubSearchContext to power an aggregation fetching top hits.Methods inherited from class org.elasticsearch.search.aggregations.support.AggregationContext
buildFieldContext, buildFieldContext, getUsageService
-
Constructor Details
-
ProductionAggregationContext
public ProductionAggregationContext(SearchExecutionContext context, BigArrays bigArrays, long bytesToPreallocate, Supplier<org.apache.lucene.search.Query> topLevelQuery, @Nullable AggregationProfiler profiler, MultiBucketConsumerService.MultiBucketConsumer multiBucketConsumer, Supplier<SubSearchContext> subSearchContextBuilder, BitsetFilterCache bitsetFilterCache, int randomSeed, LongSupplier relativeTimeInMillis, Supplier<Boolean> isCancelled, Function<org.apache.lucene.search.Query,org.apache.lucene.search.Query> filterQuery, boolean enableRewriteToFilterByFilter)
-
-
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:
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
-
getMatchingFieldNames
Description copied from class:AggregationContext
Returns a set of field names that match a regex-like pattern All field names in the returned set are guaranteed to resolve to a field- Specified by:
getMatchingFieldNames
in classAggregationContext
-
isFieldMapped
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:
IOException
-
filterQuery
public org.apache.lucene.search.Query filterQuery(org.apache.lucene.search.Query query)Description copied from class:AggregationContext
Add filters from slice or filtered aliases. If you make a new query and don't combine it with thetop level query
then you must provide it to this method.- Specified by:
filterQuery
in classAggregationContext
-
getIndexSettings
Description copied from class:AggregationContext
The settings for the index against which this search is running.- Specified by:
getIndexSettings
in classAggregationContext
-
buildSort
Description copied from class:AggregationContext
Compile a sort.- Specified by:
buildSort
in classAggregationContext
- Throws:
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 IOExceptionDescription copied from class:AggregationContext
Build a collector for sorted values specialized for aggregations.- Specified by:
buildBucketedSort
in classAggregationContext
- Throws:
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(Function<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
-
enableRewriteToFilterByFilter
public boolean enableRewriteToFilterByFilter()Description copied from class:AggregationContext
Are aggregations allowed to try to rewrite themselves intoFilterByFilterAggregator
aggregations? Often FilterByFilterAggregator is faster to execute, but it isn't always. For now this just hooks into a cluster level setting so users can disable the behavior when the existing heuristics don't detect cases where its slower.- Specified by:
enableRewriteToFilterByFilter
in classAggregationContext
-
close
public void close()
-