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 java.lang.String
NAME
static ObjectParser<HistogramAggregationBuilder,java.lang.String>
PARSER
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
-
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.protected
HistogramAggregationBuilder(HistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData)
-
Method Summary
Modifier and Type Method Description protected XContentBuilder
doXContentBody(XContentBuilder builder, ToXContent.Params params)
boolean
equals(java.lang.Object obj)
HistogramAggregationBuilder
extendedBounds(double minBound, double maxBound)
Set extended bounds on this builder: buckets betweenminBound
andmaxBound
will be created even if no documents fell into these buckets.java.lang.String
getType()
The name of the type of aggregation built by this builder.int
hashCode()
protected ValuesSourceAggregatorFactory<ValuesSource>
innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig<ValuesSource> config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder)
protected void
innerWriteTo(StreamOutput out)
Write subclass's state to the stream.double
interval()
Get the current interval that is set on this builder.HistogramAggregationBuilder
interval(double interval)
Set the interval on this builder, and return the builder so that calls can be chained.boolean
keyed()
Return whether buckets should be returned as a hash.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.double
maxBound()
Get the current maximum bound that is set on this builder.double
minBound()
Get the current minimum bound that is set on this builder.long
minDocCount()
Return the minimum count of documents that buckets need to have in order to be included in the response.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.double
offset()
Get the current offset that is set on this builder.HistogramAggregationBuilder
offset(double offset)
Set the offset on this builder, and return the builder so that calls can be chained.BucketOrder
order()
Return the order to use to sort buckets of this histogram.HistogramAggregationBuilder
order(java.util.List<BucketOrder> orders)
Sets the order in which the buckets will be returned.HistogramAggregationBuilder
order(BucketOrder order)
Set a new order on this builder and return the builder so that calls can be chained.protected ValuesSourceType
resolveScriptAny(Script script)
Provide a hook for aggregations to have finer grained control of the CoreValuesSourceType for script values.protected AggregationBuilder
shallowCopy(AggregatorFactories.Builder factoriesBuilder, java.util.Map<java.lang.String,java.lang.Object> metaData)
Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilder
andmetaData
.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
buildPipelineTree, doRewrite, getName, getPipelineAggregations, getSubAggregations, rewrite, toString
-
Field Details
-
NAME
public static final java.lang.String NAME- See Also:
- Constant Field Values
-
PARSER
-
-
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
-
resolveScriptAny
Description copied from class:ValuesSourceAggregationBuilder
Provide 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:
resolveScriptAny
in 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:AggregationBuilder
Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilder
andmetaData
. Used byAggregationBuilder.rewrite(QueryRewriteContext)
.- Specified by:
shallowCopy
in classAggregationBuilder
-
innerWriteTo
Description copied from class:ValuesSourceAggregationBuilder
Write subclass's state to the stream.- Specified by:
innerWriteTo
in 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 betweenminBound
andmaxBound
will 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 casekeyed
is 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:
doXContentBody
in classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
- Throws:
java.io.IOException
-
getType
public java.lang.String getType()Description copied from interface:BaseAggregationBuilder
The name of the type of aggregation built by this builder.- Specified by:
getType
in interfaceBaseAggregationBuilder
-
innerBuild
protected ValuesSourceAggregatorFactory<ValuesSource> innerBuild(QueryShardContext queryShardContext, ValuesSourceConfig<ValuesSource> config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws java.io.IOException- Specified by:
innerBuild
in classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
- Throws:
java.io.IOException
-
hashCode
public int hashCode()- Overrides:
hashCode
in classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-
equals
public boolean equals(java.lang.Object obj)- Overrides:
equals
in classValuesSourceAggregationBuilder<ValuesSource,HistogramAggregationBuilder>
-