Class AggregationBuilder
- java.lang.Object
-
- org.elasticsearch.search.aggregations.AggregationBuilder
-
- All Implemented Interfaces:
NamedWriteable
,Writeable
,ToXContent
,ToXContentFragment
,BaseAggregationBuilder
- Direct Known Subclasses:
AbstractAggregationBuilder
public abstract class AggregationBuilder extends java.lang.Object implements NamedWriteable, ToXContentFragment, BaseAggregationBuilder
A factory that knows how to create anAggregator
of a specific type.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
AggregationBuilder.CommonFields
Common xcontent fields shared among aggregator builders-
Nested classes/interfaces inherited from interface org.elasticsearch.common.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 Modifier and Type Field Description protected AggregatorFactories.Builder
factoriesBuilder
protected java.lang.String
name
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AggregationBuilder(java.lang.String name)
Constructs a new aggregation builder.protected
AggregationBuilder(AggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder)
-
Method Summary
Modifier and Type Method Description protected abstract AggregatorFactory<?>
build(SearchContext context, AggregatorFactory<?> parent)
Internal: build anAggregatorFactory
based on the configuration of this builder.protected AggregationBuilder
doRewrite(QueryRewriteContext queryShardContext)
Rewrites this aggregation builder into its primitive form.abstract java.util.Map<java.lang.String,java.lang.Object>
getMetaData()
Return any associated metadata with thisAggregationBuilder
.java.lang.String
getName()
Return this aggregation's name.java.util.Collection<PipelineAggregationBuilder>
getPipelineAggregations()
Return the configured set of pipeline aggregationsjava.util.Collection<AggregationBuilder>
getSubAggregations()
Return the configured set of subaggregationsAggregationBuilder
rewrite(QueryRewriteContext context)
abstract AggregationBuilder
setMetaData(java.util.Map<java.lang.String,java.lang.Object> metaData)
Associate metadata with thisAggregationBuilder
.protected abstract AggregationBuilder
shallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData)
Create a shallow copy of this builder and replacingfactoriesBuilder
andmetaData
.abstract AggregationBuilder
subAggregation(AggregationBuilder aggregation)
Add a sub aggregation to this builder.abstract AggregationBuilder
subAggregation(PipelineAggregationBuilder aggregation)
Add a sub aggregation to this builder.abstract AggregationBuilder
subAggregations(AggregatorFactories.Builder subFactories)
Internal: Registers sub-factories with this factory.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.search.aggregations.BaseAggregationBuilder
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
-
-
-
-
Field Detail
-
name
protected final java.lang.String name
-
factoriesBuilder
protected AggregatorFactories.Builder factoriesBuilder
-
-
Constructor Detail
-
AggregationBuilder
protected AggregationBuilder(java.lang.String name)
Constructs a new aggregation builder.- Parameters:
name
- The aggregation name
-
AggregationBuilder
protected AggregationBuilder(AggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder)
-
-
Method Detail
-
getName
public java.lang.String getName()
Return this aggregation's name.
-
build
protected abstract AggregatorFactory<?> build(SearchContext context, AggregatorFactory<?> parent) throws java.io.IOException
Internal: build anAggregatorFactory
based on the configuration of this builder.- Throws:
java.io.IOException
-
setMetaData
public abstract AggregationBuilder setMetaData(java.util.Map<java.lang.String,java.lang.Object> metaData)
Associate metadata with thisAggregationBuilder
.- Specified by:
setMetaData
in interfaceBaseAggregationBuilder
-
getMetaData
public abstract java.util.Map<java.lang.String,java.lang.Object> getMetaData()
Return any associated metadata with thisAggregationBuilder
.
-
subAggregation
public abstract AggregationBuilder subAggregation(AggregationBuilder aggregation)
Add a sub aggregation to this builder.
-
subAggregation
public abstract AggregationBuilder subAggregation(PipelineAggregationBuilder aggregation)
Add a sub aggregation to this builder.
-
getSubAggregations
public java.util.Collection<AggregationBuilder> getSubAggregations()
Return the configured set of subaggregations
-
getPipelineAggregations
public java.util.Collection<PipelineAggregationBuilder> getPipelineAggregations()
Return the configured set of pipeline aggregations
-
subAggregations
public abstract AggregationBuilder subAggregations(AggregatorFactories.Builder subFactories)
Internal: Registers sub-factories with this factory. The sub-factory will be responsible for the creation of sub-aggregators under the aggregator created by this factory. This is only for use byAggregatorFactories.parseAggregators(XContentParser)
.- Specified by:
subAggregations
in interfaceBaseAggregationBuilder
- Parameters:
subFactories
- The sub-factories- Returns:
- this factory (fluent interface)
-
shallowCopy
protected abstract AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData)
Create a shallow copy of this builder and replacingfactoriesBuilder
andmetaData
. Used byrewrite(QueryRewriteContext)
.
-
rewrite
public final AggregationBuilder rewrite(QueryRewriteContext context) throws java.io.IOException
- Throws:
java.io.IOException
-
doRewrite
protected AggregationBuilder doRewrite(QueryRewriteContext queryShardContext) throws java.io.IOException
Rewrites this aggregation builder into its primitive form. By default this method return the builder itself. If the builder did not change the identity reference must be returned otherwise the builder will be rewritten infinitely.- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-