Class HistogramAggregationBuilder
- java.lang.Object
-
- org.elasticsearch.search.aggregations.AggregationBuilder
-
- org.elasticsearch.search.aggregations.AbstractAggregationBuilder<AB>
-
- org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-
- org.elasticsearch.search.aggregations.bucket.histogram.HistogramAggregationBuilder
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentFragment,BaseAggregationBuilder,MultiBucketAggregationBuilder
public class HistogramAggregationBuilder extends ValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder> implements MultiBucketAggregationBuilder
A builder for histograms on numeric fields. This builder can operate on either base numeric fields, or numeric range fields. IP range fields are unsupported, and will throw at the factory layer.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
ValuesSourceAggregationBuilder.LeafOnly<VS extends ValuesSource,AB extends ValuesSourceAggregationBuilder<VS,AB>>
-
Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
AggregationBuilder.CommonFields
-
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 static StringNAME-
Fields inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
config
-
Fields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
metaData
-
Fields inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
factoriesBuilder, name
-
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
-
Constructor Summary
Constructors Modifier Constructor Description HistogramAggregationBuilder(String name)Create a new builder with the given name.HistogramAggregationBuilder(StreamInput in)Read from a stream, for internal use only.protectedHistogramAggregationBuilder(HistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String,Object> metaData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected XContentBuilderdoXContentBody(XContentBuilder builder, ToXContent.Params params)booleanequals(Object obj)HistogramAggregationBuilderextendedBounds(double minBound, double maxBound)Set extended bounds on this builder: buckets betweenminBoundandmaxBoundwill be created even if no documents fell into these buckets.StringgetType()The name of the type of aggregation built by this builder.inthashCode()protected ValuesSourceAggregatorFactory<ValuesSource>innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig<ValuesSource> config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder)protected voidinnerWriteTo(StreamOutput out)Write subclass's state to the stream.doubleinterval()Get the current interval that is set on this builder.HistogramAggregationBuilderinterval(double interval)Set the interval on this builder, and return the builder so that calls can be chained.booleankeyed()Return whether buckets should be returned as a hash.HistogramAggregationBuilderkeyed(boolean keyed)Set whether to return buckets as a hash or as an array, and return the builder so that calls can be chained.doublemaxBound()Get the current maximum bound that is set on this builder.doubleminBound()Get the current minimum bound that is set on this builder.longminDocCount()Return the minimum count of documents that buckets need to have in order to be included in the response.HistogramAggregationBuilderminDocCount(long minDocCount)Set the minimum count of matching documents that buckets need to have and return this builder so that calls can be chained.doubleoffset()Get the current offset that is set on this builder.HistogramAggregationBuilderoffset(double offset)Set the offset on this builder, and return the builder so that calls can be chained.BucketOrderorder()Return the order to use to sort buckets of this histogram.HistogramAggregationBuilderorder(List<BucketOrder> orders)Sets the order in which the buckets will be returned.HistogramAggregationBuilderorder(BucketOrder order)Set a new order on this builder and return the builder so that calls can be chained.static HistogramAggregationBuilderparse(String aggregationName, XContentParser parser)protected ValuesSourceTyperesolveScriptAny(Script script)Provide a hook for aggregations to have finer grained control of the ValuesSourceType for script values.protected AggregationBuildershallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String,Object> metaData)Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetaData.-
Methods inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
defaultValueType, doBuild, doWriteTo, field, field, format, format, internalXContent, missing, missing, resolveConfig, script, script, serializeTargetValueType, timeZone, timeZone, valueType, valueType
-
Methods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
build, getMetaData, getWriteableName, setMetaData, subAggregation, subAggregation, subAggregations, toXContent, writeTo
-
Methods inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
doRewrite, getName, getPipelineAggregations, getSubAggregations, rewrite, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
-
-
-
Field Detail
-
NAME
public static final String NAME
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
HistogramAggregationBuilder
public HistogramAggregationBuilder(String name)
Create a new builder with the given name.
-
HistogramAggregationBuilder
protected HistogramAggregationBuilder(HistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String,Object> metaData)
-
HistogramAggregationBuilder
public HistogramAggregationBuilder(StreamInput in) throws IOException
Read from a stream, for internal use only.- Throws:
IOException
-
-
Method Detail
-
parse
public static HistogramAggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException
- Throws:
IOException
-
resolveScriptAny
protected ValuesSourceType resolveScriptAny(Script script)
Description copied from class:ValuesSourceAggregationBuilderProvide a hook for aggregations to have finer grained control of the ValuesSourceType for script values. This will only be called if the user did not supply a type hint for the script. The script object is provided for reference.- Overrides:
resolveScriptAnyin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Parameters:
script- - The user supplied script- Returns:
- The ValuesSourceType we expect this script to yield.
-
shallowCopy
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String,Object> metaData)
Description copied from class:AggregationBuilderCreate a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetaData. Used byAggregationBuilder.rewrite(QueryRewriteContext).- Specified by:
shallowCopyin classAggregationBuilder
-
innerWriteTo
protected void innerWriteTo(StreamOutput out) throws IOException
Description copied from class:ValuesSourceAggregationBuilderWrite subclass's state to the stream.- Specified by:
innerWriteToin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Throws:
IOException
-
interval
public double interval()
Get the current interval that is set on this builder.
-
interval
public HistogramAggregationBuilder interval(double interval)
Set the interval on this builder, and return the builder so that calls can be chained.
-
offset
public double offset()
Get the current offset that is set on this builder.
-
offset
public HistogramAggregationBuilder offset(double offset)
Set the offset on this builder, and return the builder so that calls can be chained.
-
minBound
public double minBound()
Get the current minimum bound that is set on this builder.
-
maxBound
public double maxBound()
Get the current maximum bound that is set on this builder.
-
extendedBounds
public HistogramAggregationBuilder extendedBounds(double minBound, double maxBound)
Set extended bounds on this builder: buckets betweenminBoundandmaxBoundwill be created even if no documents fell into these buckets.- Throws:
IllegalArgumentException- if maxBound is less that minBound, or if either of the bounds are not finite.
-
order
public BucketOrder order()
Return the order to use to sort buckets of this histogram.
-
order
public HistogramAggregationBuilder order(BucketOrder order)
Set a new order on this builder and return the builder so that calls can be chained. A tie-breaker may be added to avoid non-deterministic ordering.
-
order
public HistogramAggregationBuilder order(List<BucketOrder> orders)
Sets the order in which the buckets will be returned. A tie-breaker may be added to avoid non-deterministic ordering.
-
keyed
public boolean keyed()
Return whether buckets should be returned as a hash. In casekeyedis false, buckets will be returned as an array.
-
keyed
public HistogramAggregationBuilder keyed(boolean keyed)
Set whether to return buckets as a hash or as an array, and return the builder so that calls can be chained.
-
minDocCount
public long minDocCount()
Return the minimum count of documents that buckets need to have in order to be included in the response.
-
minDocCount
public HistogramAggregationBuilder minDocCount(long minDocCount)
Set the minimum count of matching documents that buckets need to have and return this builder so that calls can be chained.
-
doXContentBody
protected XContentBuilder doXContentBody(XContentBuilder builder, ToXContent.Params params) throws IOException
- Specified by:
doXContentBodyin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Throws:
IOException
-
getType
public String getType()
Description copied from interface:BaseAggregationBuilderThe name of the type of aggregation built by this builder.- Specified by:
getTypein interfaceBaseAggregationBuilder
-
innerBuild
protected ValuesSourceAggregatorFactory<ValuesSource> innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig<ValuesSource> config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException
- Specified by:
innerBuildin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Throws:
IOException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-
-