Class TermsAggregator
java.lang.Object
org.elasticsearch.search.aggregations.BucketCollector
org.elasticsearch.search.aggregations.Aggregator
org.elasticsearch.search.aggregations.AggregatorBase
org.elasticsearch.search.aggregations.bucket.BucketsAggregator
org.elasticsearch.search.aggregations.bucket.DeferableBucketAggregator
org.elasticsearch.search.aggregations.bucket.terms.TermsAggregator
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,org.apache.lucene.search.Collector,Releasable
- Direct Known Subclasses:
GlobalOrdinalsStringTermsAggregator,LongTermsAggregator,StringTermsAggregator
public abstract class TermsAggregator extends DeferableBucketAggregator
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTermsAggregator.BucketCountThresholdsNested classes/interfaces inherited from class org.elasticsearch.search.aggregations.Aggregator
Aggregator.Parser, Aggregator.SubAggCollectionMode -
Field Summary
Fields Modifier and Type Field Description protected java.util.Set<Aggregator>aggsUsedForSortingprotected TermsAggregator.BucketCountThresholdsbucketCountThresholdsprotected Aggregator.SubAggCollectionModecollectModeprotected DocValueFormatformatprotected BucketOrderorderFields inherited from class org.elasticsearch.search.aggregations.AggregatorBase
collectableSubAggregators, context, DEFAULT_WEIGHT, name, parent, subAggregators -
Constructor Summary
Constructors Constructor Description TermsAggregator(java.lang.String name, AggregatorFactories factories, SearchContext context, Aggregator parent, TermsAggregator.BucketCountThresholds bucketCountThresholds, BucketOrder order, DocValueFormat format, Aggregator.SubAggCollectionMode collectMode, java.util.List<PipelineAggregator> pipelineAggregators, java.util.Map<java.lang.String,java.lang.Object> metaData) -
Method Summary
Modifier and Type Method Description java.util.Comparator<MultiBucketsAggregation.Bucket>bucketComparator(AggregationPath path, boolean asc)Internal Optimization for orderingInternalTerms.Buckets by a sub aggregation.protected booleanshouldDefer(Aggregator aggregator)This method should be overridden by subclasses that want to defer calculation of a child aggregation until a first pass is complete and a set of buckets has been pruned.Methods inherited from class org.elasticsearch.search.aggregations.bucket.DeferableBucketAggregator
descendsFromGlobalAggregator, doPreCollection, getDeferringCollector, runDeferredCollectionsMethods inherited from class org.elasticsearch.search.aggregations.bucket.BucketsAggregator
bucketAggregations, bucketDocCount, bucketEmptyAggregations, close, collectBucket, collectExistingBucket, consumeBucketsAndMaybeBreak, getDocCounts, grow, incrementBucketDocCount, maxBucketOrd, mergeBucketsMethods inherited from class org.elasticsearch.search.aggregations.AggregatorBase
addRequestCircuitBreakerBytes, buildEmptySubAggregations, context, doClose, doPostCollection, getLeafCollector, getLeafCollector, metaData, name, parent, pipelineAggregators, postCollection, preCollection, preGetSubLeafCollectors, scoreMode, subAggregator, subAggregators, toStringMethods inherited from class org.elasticsearch.search.aggregations.Aggregator
buildAggregation, buildEmptyAggregation, descendsFromBucketAggregator
-
Field Details
-
Constructor Details
-
TermsAggregator
public TermsAggregator(java.lang.String name, AggregatorFactories factories, SearchContext context, Aggregator parent, TermsAggregator.BucketCountThresholds bucketCountThresholds, BucketOrder order, DocValueFormat format, Aggregator.SubAggCollectionMode collectMode, java.util.List<PipelineAggregator> pipelineAggregators, java.util.Map<java.lang.String,java.lang.Object> metaData) throws java.io.IOException- Throws:
java.io.IOException
-
-
Method Details
-
bucketComparator
public java.util.Comparator<MultiBucketsAggregation.Bucket> bucketComparator(AggregationPath path, boolean asc)Internal Optimization for orderingInternalTerms.Buckets by a sub aggregation.in this phase, if the order is based on sub-aggregations, we need to use a different comparator to avoid constructing buckets for ordering purposes (we can potentially have a lot of buckets and building them will cause loads of redundant object constructions). The "special" comparators here will fetch the sub aggregation values directly from the sub aggregators bypassing bucket creation. Note that the comparator attached to the order will still be used in the reduce phase of the Aggregation.
- Parameters:
path- determines which sub aggregation to use for ordering.asc-truefor ascending order,falsefor descending.- Returns:
Comparatorto orderInternalTerms.Buckets in the desired order.
-
shouldDefer
Description copied from class:DeferableBucketAggregatorThis method should be overridden by subclasses that want to defer calculation of a child aggregation until a first pass is complete and a set of buckets has been pruned. Deferring collection will require the recording of all doc/bucketIds from the first pass and then the sub class should callDeferableBucketAggregator.runDeferredCollections(long...)for the selected set of buckets that survive the pruning.- Overrides:
shouldDeferin classDeferableBucketAggregator- Parameters:
aggregator- the child aggregator- Returns:
- true if the aggregator should be deferred until a first pass at collection has completed
-