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.CommonFieldsNested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested 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 java.lang.StringNAMEFields inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder
configFields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
metaDataFields inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
factoriesBuilder, name -
Constructor Summary
Constructors Modifier Constructor Description HistogramAggregationBuilder(java.lang.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, java.util.Map<java.lang.String,java.lang.Object> metaData) -
Method Summary
Modifier and Type Method Description protected XContentBuilderdoXContentBody(XContentBuilder builder, ToXContent.Params params)booleanequals(java.lang.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.java.lang.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(java.util.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(java.lang.String aggregationName, XContentParser parser)protected ValuesSourceTyperesolveScriptAny(Script script)Provide a hook for aggregations to have finer grained control of the CoreValuesSourceType for script values.protected AggregationBuildershallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.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, valueTypeMethods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilder
build, getMetaData, getWriteableName, setMetaData, subAggregation, subAggregation, subAggregations, toXContent, writeToMethods inherited from class org.elasticsearch.search.aggregations.AggregationBuilder
doRewrite, getName, getPipelineAggregations, getSubAggregations, rewrite, toString
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
-
Constructor Details
-
HistogramAggregationBuilder
public HistogramAggregationBuilder(java.lang.String name)Create a new builder with the given name. -
HistogramAggregationBuilder
protected HistogramAggregationBuilder(HistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData) -
HistogramAggregationBuilder
Read from a stream, for internal use only.- Throws:
java.io.IOException
-
-
Method Details
-
parse
public static HistogramAggregationBuilder parse(java.lang.String aggregationName, XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
resolveScriptAny
Description copied from class:ValuesSourceAggregationBuilderProvide a hook for aggregations to have finer grained control of the CoreValuesSourceType 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 CoreValuesSourceType we expect this script to yield.
-
shallowCopy
protected AggregationBuilder shallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.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
Description copied from class:ValuesSourceAggregationBuilderWrite subclass's state to the stream.- Specified by:
innerWriteToin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Throws:
java.io.IOException
-
interval
public double interval()Get the current interval that is set on this builder. -
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
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
Set extended bounds on this builder: buckets betweenminBoundandmaxBoundwill be created even if no documents fell into these buckets.- Throws:
java.lang.IllegalArgumentException- if maxBound is less that minBound, or if either of the bounds are not finite.
-
order
Return the order to use to sort buckets of this histogram. -
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
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
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
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 java.io.IOException- Specified by:
doXContentBodyin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Throws:
java.io.IOException
-
getType
public java.lang.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 java.io.IOException- Specified by:
innerBuildin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>- Throws:
java.io.IOException
-
hashCode
public int hashCode()- Overrides:
hashCodein classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equalsin classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-