Class Aggregator
- All Implemented Interfaces:
Closeable
,AutoCloseable
,org.apache.lucene.search.Collector
,org.elasticsearch.core.Releasable
- Direct Known Subclasses:
AdaptingAggregator
,AggregatorBase
,DeferringBucketCollector.WrappedAggregator
,ProfilingAggregator
Be careful when adding methods to this class. If possible make sure they have sensible default implementations.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Compare two buckets by their ordinal.static interface
Parses the aggregation request and creates the appropriate aggregator factory for it.static class
Aggregation mode for sub aggregations. -
Field Summary
Fields inherited from class org.elasticsearch.search.aggregations.BucketCollector
NO_OP_COLLECTOR
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbucketComparator(String key, SortOrder order)
Builds a comparator that compares two buckets aggregated by this Aggregator.abstract InternalAggregation[]
buildAggregations(long[] ordsToCollect)
Build the results of this aggregation.abstract InternalAggregation
Build an empty aggregation.Build the result of this aggregation if it is at the "top level" of the aggregation tree.void
Collect debug information to add to the profiling results.abstract String
name()
Return the name of this aggregator.abstract Aggregator
parent()
Return the parent aggregator.Resolve a sort path to the target.resolveSortPathOnValidAgg(AggregationPath.PathElement next, Iterator<AggregationPath.PathElement> path)
Resolve the next step of the sort path as though this aggregation supported sorting.abstract Aggregator
subAggregator(String name)
Return the sub aggregator with the provided name.abstract Aggregator[]
Get the aggregators running under this one.Methods inherited from class org.elasticsearch.search.aggregations.BucketCollector
getLeafCollector, postCollection, preCollection
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.apache.lucene.search.Collector
scoreMode
Methods inherited from interface org.elasticsearch.core.Releasable
close
-
Constructor Details
-
Aggregator
public Aggregator()
-
-
Method Details
-
name
Return the name of this aggregator. -
parent
Return the parent aggregator. -
subAggregator
Return the sub aggregator with the provided name. -
resolveSortPathOnValidAgg
public final Aggregator resolveSortPathOnValidAgg(AggregationPath.PathElement next, Iterator<AggregationPath.PathElement> path)Resolve the next step of the sort path as though this aggregation supported sorting. This is usually the "first step" when resolving a sort path because most aggs that support sorting their buckets aren't valid in the middle of a sort path.For example, the
terms
aggs supports sorting its buckets, but that sort path itself can't contain a differentterms
aggregation. -
resolveSortPath
public Aggregator resolveSortPath(AggregationPath.PathElement next, Iterator<AggregationPath.PathElement> path)Resolve a sort path to the target.The default implementation throws an exception but we override it on aggregations that support sorting.
-
bucketComparator
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.
-
buildAggregations
Build the results of this aggregation.- Parameters:
ordsToCollect
- the ordinals of the buckets that we want to collect from this aggregation- Returns:
- the results for each ordinal, in the same order as the array of ordinals
- Throws:
IOException
-
buildTopLevel
Build the result of this aggregation if it is at the "top level" of the aggregation tree. If, instead, it is a sub-aggregation of another aggregation then the aggregation that contains it will callbuildAggregations(long[])
.- Throws:
IOException
-
buildEmptyAggregation
Build an empty aggregation. -
collectDebugInfo
Collect debug information to add to the profiling results. This will only be called if the aggregation is being profiled.Well behaved implementations will always call the superclass implementation just in case it has something interesting. They will also only add objects which can be serialized with
StreamOutput.writeGenericValue(Object)
andXContentBuilder.value(Object)
. And they'll have an integration test. -
subAggregators
Get the aggregators running under this one.
-