Class InternalMultiBucketAggregation<A extends InternalMultiBucketAggregation,B extends InternalMultiBucketAggregation.InternalBucket>
java.lang.Object
org.elasticsearch.search.aggregations.InternalAggregation
org.elasticsearch.search.aggregations.InternalMultiBucketAggregation<A,B>
- All Implemented Interfaces:
NamedWriteable
,Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
,Aggregation
,MultiBucketsAggregation
- Direct Known Subclasses:
AbstractInternalTerms
,InternalAdjacencyMatrix
,InternalAutoDateHistogram
,InternalBinaryRange
,InternalComposite
,InternalDateHistogram
,InternalFilters
,InternalGeoGrid
,InternalHistogram
,InternalRange
,InternalRareTerms
,InternalSignificantTerms
,InternalVariableWidthHistogram
public abstract class InternalMultiBucketAggregation<A extends InternalMultiBucketAggregation,B extends InternalMultiBucketAggregation.InternalBucket>
extends InternalAggregation
implements MultiBucketsAggregation
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.InternalAggregation
InternalAggregation.ReduceContext, InternalAggregation.ReduceContextBuilder
Nested classes/interfaces inherited from interface org.elasticsearch.search.aggregations.Aggregation
Aggregation.CommonFields
Nested classes/interfaces inherited from interface org.elasticsearch.search.aggregations.bucket.MultiBucketsAggregation
MultiBucketsAggregation.Bucket
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from class org.elasticsearch.search.aggregations.InternalAggregation
metadata, name
Fields inherited from interface org.elasticsearch.search.aggregations.Aggregation
TYPED_KEYS_DELIMITER
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionInternalMultiBucketAggregation(String name, Map<String,Object> metadata)
protected
Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionRewrite the sub-aggregations in the buckets in this aggregation.static int
Counts the number of inner buckets inside the providedAggregation
static int
Counts the number of inner buckets inside the providedInternalMultiBucketAggregation.InternalBucket
abstract A
Create a new copy of thisAggregation
with the same settings as thisAggregation
and contains the provided buckets.abstract B
createBucket(InternalAggregations aggregations, B prototype)
Create a newInternalMultiBucketAggregation.InternalBucket
using the provided prototype bucket and aggregations.void
forEachBucket(Consumer<InternalAggregations> consumer)
Run a Consumer over all buckets in this aggregation.getProperty(List<String> path)
protected boolean
Signal the framework if the InternalAggregation.reduce(List, ReduceContext) phase needs to be called when there is only one InternalAggregation.protected abstract B
reduceBucket(List<B> buckets, InternalAggregation.ReduceContext context)
Reduce a list of same-keyed buckets (from multiple shards) to a single bucket.reducePipelines(InternalAggregation reducedAggs, InternalAggregation.ReduceContext reduceContext, PipelineAggregator.PipelineTree pipelineTree)
A multi-bucket agg needs to first reduce the buckets and *their* pipelines before allowing sibling pipelines to materialize.Methods inherited from class org.elasticsearch.search.aggregations.InternalAggregation
doWriteTo, doXContentBody, equals, getMetadata, getName, getProperty, getType, hashCode, isMapped, mergePipelineTreeForBWCSerialization, pipelineAggregatorsForBwcSerialization, readSize, reduce, sortValue, sortValue, toString, toXContent, writeSize, writeTo
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.search.aggregations.Aggregation
getMetadata, getName, getType
Methods inherited from interface org.elasticsearch.common.io.stream.NamedWriteable
getWriteableName
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContent
toXContent
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Constructor Details
-
InternalMultiBucketAggregation
-
InternalMultiBucketAggregation
Read from a stream.- Throws:
IOException
-
-
Method Details
-
create
Create a new copy of thisAggregation
with the same settings as thisAggregation
and contains the provided buckets.- Parameters:
buckets
- the buckets to use in the newAggregation
- Returns:
- the new
Aggregation
-
createBucket
Create a newInternalMultiBucketAggregation.InternalBucket
using the provided prototype bucket and aggregations.- Parameters:
aggregations
- the aggregations for the new bucketprototype
- the bucket to use as a prototype- Returns:
- the new bucket
-
reduceBucket
Reduce a list of same-keyed buckets (from multiple shards) to a single bucket. This requires all buckets to have the same key. -
getBuckets
- Specified by:
getBuckets
in interfaceMultiBucketsAggregation
- Returns:
- The buckets of this aggregation.
-
getProperty
- Specified by:
getProperty
in classInternalAggregation
-
countInnerBucket
Counts the number of inner buckets inside the providedInternalMultiBucketAggregation.InternalBucket
-
countInnerBucket
Counts the number of inner buckets inside the providedAggregation
-
reducePipelines
public final InternalAggregation reducePipelines(InternalAggregation reducedAggs, InternalAggregation.ReduceContext reduceContext, PipelineAggregator.PipelineTree pipelineTree)A multi-bucket agg needs to first reduce the buckets and *their* pipelines before allowing sibling pipelines to materialize.- Overrides:
reducePipelines
in classInternalAggregation
-
copyWithRewritenBuckets
public InternalAggregation copyWithRewritenBuckets(Function<InternalAggregations,InternalAggregations> rewriter)Description copied from class:InternalAggregation
Rewrite the sub-aggregations in the buckets in this aggregation. Returns a copy of this InternalAggregation with the rewritten buckets, or, if there aren't any modifications to the buckets then this method will return this aggregation. Either way, it doesn't modify this aggregation.Implementers of this should call the
rewriter
once per bucket with its InternalAggregations. Therewriter
should returnnull
if it doen't have any rewriting to do or it should return a new InternalAggregations to make changs.The default implementation throws an exception because most aggregations don't have buckets in them. It should be overridden by aggregations that contain buckets. Implementers should respect the description above.
- Overrides:
copyWithRewritenBuckets
in classInternalAggregation
-
mustReduceOnSingleInternalAgg
protected boolean mustReduceOnSingleInternalAgg()Description copied from class:InternalAggregation
Signal the framework if the InternalAggregation.reduce(List, ReduceContext) phase needs to be called when there is only one InternalAggregation.- Specified by:
mustReduceOnSingleInternalAgg
in classInternalAggregation
-
forEachBucket
Description copied from class:InternalAggregation
Run a Consumer over all buckets in this aggregation.- Overrides:
forEachBucket
in classInternalAggregation
-