Class BucketsAggregator
java.lang.Object
org.elasticsearch.search.aggregations.BucketCollector
org.elasticsearch.search.aggregations.Aggregator
org.elasticsearch.search.aggregations.AggregatorBase
org.elasticsearch.search.aggregations.bucket.BucketsAggregator
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,org.apache.lucene.search.Collector
,Releasable
- Direct Known Subclasses:
AdjacencyMatrixAggregator
,BinaryRangeAggregator
,DeferableBucketAggregator
,FilterAggregator
,FiltersAggregator
,GeoGridAggregator
,GlobalAggregator
,MissingAggregator
,NestedAggregator
,RangeAggregator
,RangeHistogramAggregator
,ReverseNestedAggregator
,SignificantTextAggregator
public abstract class BucketsAggregator extends AggregatorBase
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.Aggregator
Aggregator.BucketComparator, Aggregator.Parser, Aggregator.SubAggCollectionMode
-
Field Summary
Fields inherited from class org.elasticsearch.search.aggregations.AggregatorBase
collectableSubAggregators, context, DEFAULT_WEIGHT, name, parent, subAggregators
-
Constructor Summary
Constructors Constructor Description BucketsAggregator(java.lang.String name, AggregatorFactories factories, SearchContext context, Aggregator parent, java.util.List<PipelineAggregator> pipelineAggregators, java.util.Map<java.lang.String,java.lang.Object> metaData)
-
Method Summary
Modifier and Type Method Description protected InternalAggregations
bucketAggregations(long bucket)
Required method to build the child aggregations of the given bucket (identified by the bucket ordinal).Aggregator.BucketComparator
bucketComparator(java.lang.String key, SortOrder order)
Builds a comparator that compares two buckets aggregated by this Aggregator.int
bucketDocCount(long bucketOrd)
Utility method to return the number of documents that fell in the given bucket (identified by the bucket ordinal)protected InternalAggregations
bucketEmptyAggregations()
Utility method to build empty aggregations of the sub aggregators.void
close()
Called upon release of the aggregator.void
collectBucket(LeafBucketCollector subCollector, int doc, long bucketOrd)
Utility method to collect the given doc in the given bucket (identified by the bucket ordinal)void
collectExistingBucket(LeafBucketCollector subCollector, int doc, long bucketOrd)
Same ascollectBucket(LeafBucketCollector, int, long)
, but doesn't check if the docCounts needs to be re-sized.protected void
consumeBucketsAndMaybeBreak(int count)
Addscount
buckets to the global count for the request and fails if this number is greater than the maximum number of buckets allowed in a responseIntArray
getDocCounts()
void
grow(long maxBucketOrd)
Ensure there are at leastmaxBucketOrd
buckets available.void
incrementBucketDocCount(long bucketOrd, int inc)
Utility method to increment the doc counts of the given bucket (identified by the bucket ordinal)long
maxBucketOrd()
Return an upper bound of the maximum bucket ordinal seen so far.void
mergeBuckets(long[] mergeMap, long newNumBuckets)
Aggregator
resolveSortPath(AggregationPath.PathElement next, java.util.Iterator<AggregationPath.PathElement> path)
Resolve a sort path to the target.Methods inherited from class org.elasticsearch.search.aggregations.AggregatorBase
addRequestCircuitBreakerBytes, buildEmptySubAggregations, context, doClose, doPostCollection, doPreCollection, getLeafCollector, getLeafCollector, metaData, name, parent, pipelineAggregators, postCollection, preCollection, preGetSubLeafCollectors, scoreMode, subAggregator, subAggregators, toString
Methods inherited from class org.elasticsearch.search.aggregations.Aggregator
buildAggregation, buildEmptyAggregation, descendsFromBucketAggregator, resolveSortPathOnValidAgg
-
Constructor Details
-
BucketsAggregator
public BucketsAggregator(java.lang.String name, AggregatorFactories factories, SearchContext context, Aggregator parent, 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
-
maxBucketOrd
public final long maxBucketOrd()Return an upper bound of the maximum bucket ordinal seen so far. -
grow
public final void grow(long maxBucketOrd)Ensure there are at leastmaxBucketOrd
buckets available. -
collectBucket
public final void collectBucket(LeafBucketCollector subCollector, int doc, long bucketOrd) throws java.io.IOExceptionUtility method to collect the given doc in the given bucket (identified by the bucket ordinal)- Throws:
java.io.IOException
-
collectExistingBucket
public final void collectExistingBucket(LeafBucketCollector subCollector, int doc, long bucketOrd) throws java.io.IOExceptionSame ascollectBucket(LeafBucketCollector, int, long)
, but doesn't check if the docCounts needs to be re-sized.- Throws:
java.io.IOException
-
mergeBuckets
public final void mergeBuckets(long[] mergeMap, long newNumBuckets) -
getDocCounts
-
incrementBucketDocCount
public final void incrementBucketDocCount(long bucketOrd, int inc)Utility method to increment the doc counts of the given bucket (identified by the bucket ordinal) -
bucketDocCount
public final int bucketDocCount(long bucketOrd)Utility method to return the number of documents that fell in the given bucket (identified by the bucket ordinal) -
consumeBucketsAndMaybeBreak
protected final void consumeBucketsAndMaybeBreak(int count)Addscount
buckets to the global count for the request and fails if this number is greater than the maximum number of buckets allowed in a response -
bucketAggregations
Required method to build the child aggregations of the given bucket (identified by the bucket ordinal).- Throws:
java.io.IOException
-
bucketEmptyAggregations
Utility method to build empty aggregations of the sub aggregators. -
close
public final void close()Description copied from class:AggregatorBase
Called upon release of the aggregator.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Specified by:
close
in interfaceReleasable
- Overrides:
close
in classAggregatorBase
-
resolveSortPath
public Aggregator resolveSortPath(AggregationPath.PathElement next, java.util.Iterator<AggregationPath.PathElement> path)Description copied from class:Aggregator
Resolve a sort path to the target.The default implementation throws an exception but we override it on aggregations that support sorting.
- Overrides:
resolveSortPath
in classAggregator
-
bucketComparator
Description copied from class:Aggregator
Builds a comparator that compares two buckets aggregated by this Aggregator.The default implementation throws an exception but we override it on aggregations that support sorting.
- Overrides:
bucketComparator
in classAggregator
-