Class InternalSingleBucketAggregation
java.lang.Object
org.elasticsearch.search.aggregations.InternalAggregation
org.elasticsearch.search.aggregations.bucket.InternalSingleBucketAggregation
- All Implemented Interfaces:
NamedWriteable
,Writeable
,Aggregation
,SingleBucketAggregation
,HasAggregations
,ToXContent
,ToXContentFragment
- Direct Known Subclasses:
InternalFilter
,InternalGlobal
,InternalMissing
,InternalNested
,InternalReverseNested
,InternalSampler
public abstract class InternalSingleBucketAggregation
extends InternalAggregation
implements SingleBucketAggregation
A base class for all the single bucket aggregations.
-
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.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, 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.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ModifierConstructorDescriptionprotected
InternalSingleBucketAggregation
(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) Creates a single bucket aggregation.protected
Read from a stream. -
Method Summary
Modifier and TypeMethodDescriptionRewrite the sub-aggregations in the buckets in this aggregation.create
(InternalAggregations subAggregations) Create a new copy of thisAggregation
with the same settings as thisAggregation
and contains the provided sub-aggregations.protected void
doWriteTo
(StreamOutput out) doXContentBody
(XContentBuilder builder, ToXContent.Params params) boolean
void
forEachBucket
(Consumer<InternalAggregations> consumer) Run a Consumer over all buckets in this aggregation.long
getProperty
(List<String> path) int
hashCode()
protected boolean
Signal the framework if the InternalAggregation.reduce(List, ReduceContext) phase needs to be called when there is only one InternalAggregation.protected abstract InternalSingleBucketAggregation
newAggregation
(String name, long docCount, InternalAggregations subAggregations) Create a new empty sub aggregation.reduce
(List<InternalAggregation> aggregations, InternalAggregation.ReduceContext reduceContext) Reduces the given aggregations to a single one and returns it.final InternalAggregation
reducePipelines
(InternalAggregation reducedAggs, InternalAggregation.ReduceContext reduceContext, PipelineAggregator.PipelineTree pipelineTree) Amulti-bucket agg needs to first reduce the buckets and *their* pipelines before allowing sibling pipelines to materialize.final double
Get value to use when sorting by this aggregation.final double
Get value to use when sorting by a descendant of this aggregation.Methods inherited from class org.elasticsearch.search.aggregations.InternalAggregation
getMetadata, getName, getProperty, getType, isMapped, mergePipelineTreeForBWCSerialization, pipelineAggregatorsForBwcSerialization, readSize, 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.xcontent.ToXContent
toXContent
Methods inherited from interface org.elasticsearch.xcontent.ToXContentFragment
isFragment
-
Constructor Details
-
InternalSingleBucketAggregation
protected InternalSingleBucketAggregation(String name, long docCount, InternalAggregations aggregations, Map<String, Object> metadata) Creates a single bucket aggregation.- Parameters:
name
- The aggregation name.docCount
- The document count in the single bucket.aggregations
- The already built sub-aggregations that are associated with the bucket.
-
InternalSingleBucketAggregation
Read from a stream.- Throws:
IOException
-
-
Method Details
-
doWriteTo
- Specified by:
doWriteTo
in classInternalAggregation
- Throws:
IOException
-
getDocCount
public long getDocCount()- Specified by:
getDocCount
in interfaceSingleBucketAggregation
- Returns:
- The number of documents in this bucket
-
getAggregations
- Specified by:
getAggregations
in interfaceHasAggregations
- Specified by:
getAggregations
in interfaceSingleBucketAggregation
- Returns:
- The sub-aggregations of this bucket
-
create
Create a new copy of thisAggregation
with the same settings as thisAggregation
and contains the provided sub-aggregations.- Parameters:
subAggregations
- the buckets to use in the newAggregation
- Returns:
- the new
Aggregation
-
newAggregation
protected abstract InternalSingleBucketAggregation newAggregation(String name, long docCount, InternalAggregations subAggregations) Create a new empty sub aggregation. This must be a new instance on each call. -
reduce
public InternalAggregation reduce(List<InternalAggregation> aggregations, InternalAggregation.ReduceContext reduceContext) Description copied from class:InternalAggregation
Reduces the given aggregations to a single one and returns it. In most cases, the assumption will be the all given aggregations are of the same type (the same type as this aggregation). For best efficiency, when implementing, try reusing an existing instance (typically the first in the given list) to save on redundant object construction.- Specified by:
reduce
in classInternalAggregation
- See Also:
-
reducePipelines
public final InternalAggregation reducePipelines(InternalAggregation reducedAggs, InternalAggregation.ReduceContext reduceContext, PipelineAggregator.PipelineTree pipelineTree) Amulti-bucket agg needs to first reduce the buckets and *their* pipelines before allowing sibling pipelines to materialize.- Overrides:
reducePipelines
in classInternalAggregation
-
getProperty
- Specified by:
getProperty
in classInternalAggregation
-
doXContentBody
public XContentBuilder doXContentBody(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
doXContentBody
in classInternalAggregation
- Throws:
IOException
-
sortValue
Description copied from class:InternalAggregation
Get value to use when sorting by this aggregation.- Overrides:
sortValue
in classInternalAggregation
-
sortValue
public final double sortValue(AggregationPath.PathElement head, Iterator<AggregationPath.PathElement> tail) Description copied from class:InternalAggregation
Get value to use when sorting by a descendant of this aggregation.- Overrides:
sortValue
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
-
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
-
forEachBucket
Description copied from class:InternalAggregation
Run a Consumer over all buckets in this aggregation.- Overrides:
forEachBucket
in classInternalAggregation
-
equals
- Overrides:
equals
in classInternalAggregation
-
hashCode
public int hashCode()- Overrides:
hashCode
in classInternalAggregation
-