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
ConstructorsConstructorDescriptionProductionAggregationContext(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 TypeMethodDescriptionvoidaddReleasable(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.QuerybuildQuery(QueryBuilder builder)Build a query.buildSort(List<SortBuilder<?>> sortBuilders)Compile a sort.voidclose()<FactoryType>
FactoryTypecompile(Script script, ScriptContext<FactoryType> scriptContext)Compile a script.booleanAre aggregations allowed to try to rewrite themselves intoFilterByFilterAggregatoraggregations? Often FilterByFilterAggregator is faster to execute, but it isn't always.org.apache.lucene.search.QueryfilterQuery(org.apache.lucene.search.Query query)Add filters from slice or filtered aliases.getFieldType(String path)Lookup aMappedFieldTypeby path.org.apache.lucene.analysis.AnalyzergetIndexAnalyzer(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.longHow many millis have passed since we started the search?TheValuesSourceRegistryto resolveAggregators and the like.booleanIs this request cacheable? Requests that have non-deterministic queries or scripts aren't cachable.booleanHas the search been cancelled?booleanisFieldMapped(String field)Returns true if the field identified by the provided name is mapped, false otherwiselookup()Fetch the sharedSearchLookup.Access the nested scope.longThe time in milliseconds that is shared across all resources involved.Wrap the aggregator for profiling if profiling is enabled.booleanAre we profiling the aggregation?org.apache.lucene.search.Queryquery()The query at the top level of the search in which these aggregations are running.org.apache.lucene.search.IndexSearchersearcher()The searcher that will execute this query.intGet 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:AggregationContextThe query at the top level of the search in which these aggregations are running.- Specified by:
queryin classAggregationContext
-
profileIfEnabled
Description copied from class:AggregationContextWrap the aggregator for profiling if profiling is enabled.- Specified by:
profileIfEnabledin classAggregationContext- Throws:
IOException
-
profiling
public boolean profiling()Description copied from class:AggregationContextAre we profiling the aggregation?- Specified by:
profilingin classAggregationContext
-
nowInMillis
public long nowInMillis()Description copied from class:AggregationContextThe time in milliseconds that is shared across all resources involved. Even across shards and nodes.- Specified by:
nowInMillisin classAggregationContext
-
buildFieldData
Description copied from class:AggregationContextBuild field data.- Specified by:
buildFieldDatain classAggregationContext
-
getFieldType
Description copied from class:AggregationContextLookup aMappedFieldTypeby path.- Specified by:
getFieldTypein classAggregationContext
-
getMatchingFieldNames
Description copied from class:AggregationContextReturns 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:
getMatchingFieldNamesin classAggregationContext
-
isFieldMapped
Description copied from class:AggregationContextReturns true if the field identified by the provided name is mapped, false otherwise- Specified by:
isFieldMappedin classAggregationContext
-
compile
Description copied from class:AggregationContextCompile a script.- Specified by:
compilein classAggregationContext
-
lookup
Description copied from class:AggregationContextFetch the sharedSearchLookup.- Specified by:
lookupin classAggregationContext
-
getValuesSourceRegistry
Description copied from class:AggregationContextTheValuesSourceRegistryto resolveAggregators and the like.- Specified by:
getValuesSourceRegistryin classAggregationContext
-
bigArrays
Description copied from class:AggregationContextUtility to share and track large arrays.- Specified by:
bigArraysin classAggregationContext
-
searcher
public org.apache.lucene.search.IndexSearcher searcher()Description copied from class:AggregationContextThe searcher that will execute this query.- Specified by:
searcherin classAggregationContext
-
buildQuery
Description copied from class:AggregationContextBuild a query.- Specified by:
buildQueryin classAggregationContext- Throws:
IOException
-
filterQuery
public org.apache.lucene.search.Query filterQuery(org.apache.lucene.search.Query query)Description copied from class:AggregationContextAdd filters from slice or filtered aliases. If you make a new query and don't combine it with thetop level querythen you must provide it to this method.- Specified by:
filterQueryin classAggregationContext
-
getIndexSettings
Description copied from class:AggregationContextThe settings for the index against which this search is running.- Specified by:
getIndexSettingsin classAggregationContext
-
buildSort
Description copied from class:AggregationContextCompile a sort.- Specified by:
buildSortin classAggregationContext- Throws:
IOException
-
getObjectMapper
Description copied from class:AggregationContextFind anObjectMapper.- Specified by:
getObjectMapperin classAggregationContext
-
nestedScope
Description copied from class:AggregationContextAccess the nested scope. Stay away from this unless you are dealing with nested.- Specified by:
nestedScopein classAggregationContext
-
subSearchContext
Description copied from class:AggregationContextBuild a SubSearchContext to power an aggregation fetching top hits. Try to avoid using this because it pulls in a ton of dependencies.- Specified by:
subSearchContextin classAggregationContext
-
addReleasable
Description copied from class:AggregationContextCause this aggregation to be released when the search is finished.- Specified by:
addReleasablein classAggregationContext
-
multiBucketConsumer
- Specified by:
multiBucketConsumerin classAggregationContext
-
bitsetFilterCache
Description copied from class:AggregationContextGet the filter cache.- Specified by:
bitsetFilterCachein classAggregationContext
-
buildBucketedSort
public BucketedSort buildBucketedSort(SortBuilder<?> sort, int bucketSize, BucketedSort.ExtraData extra) throws IOExceptionDescription copied from class:AggregationContextBuild a collector for sorted values specialized for aggregations.- Specified by:
buildBucketedSortin classAggregationContext- Throws:
IOException
-
shardRandomSeed
public int shardRandomSeed()Description copied from class:AggregationContextGet a deterministic random seed based for this particular shard.- Specified by:
shardRandomSeedin classAggregationContext
-
getRelativeTimeInMillis
public long getRelativeTimeInMillis()Description copied from class:AggregationContextHow many millis have passed since we started the search?- Specified by:
getRelativeTimeInMillisin classAggregationContext
-
isCancelled
public boolean isCancelled()Description copied from class:AggregationContextHas the search been cancelled?This'll require a
volatileread.- Specified by:
isCancelledin classAggregationContext
-
breaker
Description copied from class:AggregationContextThe circuit breaker used to account for aggs.- Specified by:
breakerin classAggregationContext
-
getIndexAnalyzer
public org.apache.lucene.analysis.Analyzer getIndexAnalyzer(Function<String,NamedAnalyzer> unindexedFieldAnalyzer)Description copied from class:AggregationContextReturn the index-time analyzer for the current index- Specified by:
getIndexAnalyzerin classAggregationContext- Parameters:
unindexedFieldAnalyzer- a function that builds an analyzer for unindexed fields
-
indexVersionCreated
- Specified by:
indexVersionCreatedin classAggregationContext
-
isCacheable
public boolean isCacheable()Description copied from class:AggregationContextIs this request cacheable? Requests that have non-deterministic queries or scripts aren't cachable.- Specified by:
isCacheablein classAggregationContext
-
enableRewriteToFilterByFilter
public boolean enableRewriteToFilterByFilter()Description copied from class:AggregationContextAre aggregations allowed to try to rewrite themselves intoFilterByFilterAggregatoraggregations? 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:
enableRewriteToFilterByFilterin classAggregationContext
-
close
public void close()
-