Class DateHistogramAggregationBuilder
- java.lang.Object
-
- org.elasticsearch.search.aggregations.AggregationBuilder
-
- org.elasticsearch.search.aggregations.AbstractAggregationBuilder<AB>
-
- org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder<ValuesSource,DateHistogramAggregationBuilder>
-
- org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder
-
- All Implemented Interfaces:
NamedWriteable,Writeable,ToXContent,ToXContentFragment,BaseAggregationBuilder,DateIntervalConsumer,MultiBucketAggregationBuilder
public class DateHistogramAggregationBuilder extends ValuesSourceAggregationBuilder<ValuesSource,DateHistogramAggregationBuilder> implements MultiBucketAggregationBuilder, DateIntervalConsumer
A builder for histograms on date fields.
-
-
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 Map<String,Rounding.DateTimeUnit>DATE_FIELD_UNITSstatic 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 DateHistogramAggregationBuilder(String name)Create a new builder with the given name.DateHistogramAggregationBuilder(StreamInput in)Read from a stream, for internal use only.protectedDateHistogramAggregationBuilder(DateHistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String,Object> metaData)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description DateHistogramAggregationBuildercalendarInterval(DateHistogramInterval interval)Sets the interval of the DateHistogram using calendar units (`1d`, `1w`, `1M`, etc).DateHistogramIntervaldateHistogramInterval()Deprecated.DateHistogramAggregationBuilderdateHistogramInterval(DateHistogramInterval interval)Deprecated.protected XContentBuilderdoXContentBody(XContentBuilder builder, ToXContent.Params params)booleanequals(Object obj)ExtendedBoundsextendedBounds()Return extended bounds for this histogram, ornullif none are set.DateHistogramAggregationBuilderextendedBounds(ExtendedBounds extendedBounds)Set extended bounds on this histogram, so that buckets would also be generated on intervals that did not match any documents.DateHistogramAggregationBuilderfixedInterval(DateHistogramInterval interval)Sets the interval of the DateHistogram using fixed units (`1ms`, `1s`, `10m`, `4h`, etc).DateHistogramIntervalgetCalendarInterval()Returns the interval as a date time unit if and only if it was configured as a calendar interval originally.DateHistogramIntervalgetFixedInterval()Returns the interval as a fixed time unit if and only if it was configured as a fixed interval originally.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.longinterval()Deprecated.DateHistogramAggregationBuilderinterval(long interval)Deprecated.booleankeyed()Return whether buckets should be returned as a hash.DateHistogramAggregationBuilderkeyed(boolean keyed)Set whether to return buckets as a hash or as an array, and return the builder so that calls can be chained.longminDocCount()Return the minimum count of documents that buckets need to have in order to be included in the response.DateHistogramAggregationBuilderminDocCount(long minDocCount)Set the minimum count of matching documents that buckets need to have and return this builder so that calls can be chained.longoffset()Get the offset to use when rounding, which is a number of milliseconds.DateHistogramAggregationBuilderoffset(long offset)Set the offset on this builder, which is a number of milliseconds, and return the builder so that calls can be chained.DateHistogramAggregationBuilderoffset(String offset)Set the offset on this builder, as a time value, and return the builder so that calls can be chained.BucketOrderorder()Return the order to use to sort buckets of this histogram.DateHistogramAggregationBuilderorder(List<BucketOrder> orders)Sets the order in which the buckets will be returned.DateHistogramAggregationBuilderorder(BucketOrder order)Set a new order on this builder and return the builder so that calls can be chained.static DateHistogramAggregationBuilderparse(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
-
DATE_FIELD_UNITS
public static final Map<String,Rounding.DateTimeUnit> DATE_FIELD_UNITS
-
-
Constructor Detail
-
DateHistogramAggregationBuilder
public DateHistogramAggregationBuilder(String name)
Create a new builder with the given name.
-
DateHistogramAggregationBuilder
protected DateHistogramAggregationBuilder(DateHistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String,Object> metaData)
-
DateHistogramAggregationBuilder
public DateHistogramAggregationBuilder(StreamInput in) throws IOException
Read from a stream, for internal use only.- Throws:
IOException
-
-
Method Detail
-
parse
public static DateHistogramAggregationBuilder parse(String aggregationName, XContentParser parser) throws IOException
- Throws:
IOException
-
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
-
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,DateHistogramAggregationBuilder>- Parameters:
script- - The user supplied script- Returns:
- The ValuesSourceType we expect this script to yield.
-
innerWriteTo
protected void innerWriteTo(StreamOutput out) throws IOException
Description copied from class:ValuesSourceAggregationBuilderWrite subclass's state to the stream.- Specified by:
innerWriteToin classValuesSourceAggregationBuilder<ValuesSource,DateHistogramAggregationBuilder>- Throws:
IOException
-
interval
@Deprecated public long interval()
Deprecated.Get the current interval in milliseconds that is set on this builder.- Specified by:
intervalin interfaceDateIntervalConsumer
-
interval
@Deprecated public DateHistogramAggregationBuilder interval(long interval)
Deprecated.Set the interval on this builder, and return the builder so that calls can be chained. If bothinterval()anddateHistogramInterval()are set, then thedateHistogramInterval()wins.- Specified by:
intervalin interfaceDateIntervalConsumer- Since:
- 7.2.0
-
dateHistogramInterval
@Deprecated public DateHistogramInterval dateHistogramInterval()
Deprecated.Get the current date interval that is set on this builder.- Specified by:
dateHistogramIntervalin interfaceDateIntervalConsumer
-
dateHistogramInterval
@Deprecated public DateHistogramAggregationBuilder dateHistogramInterval(DateHistogramInterval interval)
Deprecated.Set the interval on this builder, and return the builder so that calls can be chained. If bothinterval()anddateHistogramInterval()are set, then thedateHistogramInterval()wins.- Specified by:
dateHistogramIntervalin interfaceDateIntervalConsumer- Since:
- 7.2.0
-
calendarInterval
public DateHistogramAggregationBuilder calendarInterval(DateHistogramInterval interval)
Sets the interval of the DateHistogram using calendar units (`1d`, `1w`, `1M`, etc). These units are calendar-aware, meaning they respect leap additions, variable days per month, etc. This is mutually exclusive withfixedInterval(DateHistogramInterval)- Specified by:
calendarIntervalin interfaceDateIntervalConsumer- Parameters:
interval- The calendar interval to use with the aggregation
-
fixedInterval
public DateHistogramAggregationBuilder fixedInterval(DateHistogramInterval interval)
Sets the interval of the DateHistogram using fixed units (`1ms`, `1s`, `10m`, `4h`, etc). These are not calendar aware and are simply multiples of fixed, SI units. This is mutually exclusive withcalendarInterval(DateHistogramInterval)- Specified by:
fixedIntervalin interfaceDateIntervalConsumer- Parameters:
interval- The fixed interval to use with the aggregation
-
getCalendarInterval
public DateHistogramInterval getCalendarInterval()
Returns the interval as a date time unit if and only if it was configured as a calendar interval originally. Returns null otherwise.
-
getFixedInterval
public DateHistogramInterval getFixedInterval()
Returns the interval as a fixed time unit if and only if it was configured as a fixed interval originally. Returns null otherwise.
-
offset
public long offset()
Get the offset to use when rounding, which is a number of milliseconds.
-
offset
public DateHistogramAggregationBuilder offset(long offset)
Set the offset on this builder, which is a number of milliseconds, and return the builder so that calls can be chained.
-
offset
public DateHistogramAggregationBuilder offset(String offset)
Set the offset on this builder, as a time value, and return the builder so that calls can be chained.
-
extendedBounds
public ExtendedBounds extendedBounds()
Return extended bounds for this histogram, ornullif none are set.
-
extendedBounds
public DateHistogramAggregationBuilder extendedBounds(ExtendedBounds extendedBounds)
Set extended bounds on this histogram, so that buckets would also be generated on intervals that did not match any documents.
-
order
public BucketOrder order()
Return the order to use to sort buckets of this histogram.
-
order
public DateHistogramAggregationBuilder 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 DateHistogramAggregationBuilder 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 DateHistogramAggregationBuilder 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 DateHistogramAggregationBuilder 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,DateHistogramAggregationBuilder>- 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,DateHistogramAggregationBuilder>- Throws:
IOException
-
hashCode
public int hashCode()
- Overrides:
hashCodein classValuesSourceAggregationBuilder<ValuesSource,DateHistogramAggregationBuilder>
-
equals
public boolean equals(Object obj)
- Overrides:
equalsin classValuesSourceAggregationBuilder<ValuesSource,DateHistogramAggregationBuilder>
-
-