Module org.elasticsearch.server
Class DateHistogramAggregationBuilder
java.lang.Object
org.elasticsearch.search.aggregations.AggregationBuilder
org.elasticsearch.search.aggregations.AbstractAggregationBuilder<AB>
org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramAggregationBuilder
- All Implemented Interfaces:
- NamedWriteable,- VersionedNamedWriteable,- Writeable,- Rewriteable<AggregationBuilder>,- BaseAggregationBuilder,- DateIntervalConsumer<DateHistogramAggregationBuilder>,- ToXContent,- ToXContentFragment
public class DateHistogramAggregationBuilder
extends ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
implements DateIntervalConsumer<DateHistogramAggregationBuilder>
A builder for histograms on date fields.
- 
Nested Class SummaryNested classes/interfaces inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilderValuesSourceAggregationBuilder.LeafOnly<VS extends ValuesSource,AB extends ValuesSourceAggregationBuilder<AB>>, ValuesSourceAggregationBuilder.MetricsAggregationBuilder<VS extends ValuesSource, AB extends ValuesSourceAggregationBuilder<AB>>, ValuesSourceAggregationBuilder.SingleMetricAggregationBuilder<VS extends ValuesSource, AB extends ValuesSourceAggregationBuilder<AB>> Nested classes/interfaces inherited from class org.elasticsearch.search.aggregations.AggregationBuilderAggregationBuilder.BucketCardinality, AggregationBuilder.CommonFieldsNested classes/interfaces inherited from interface org.elasticsearch.xcontent.ToXContentToXContent.DelegatingMapParams, ToXContent.MapParams, ToXContent.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.WriteableWriteable.Reader<V>, Writeable.Writer<V>
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final Map<String,Rounding.DateTimeUnit> static final Stringstatic final ObjectParser<DateHistogramAggregationBuilder,String> Fields inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilderconfigFields inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuildermetadataFields inherited from class org.elasticsearch.search.aggregations.AggregationBuilderDEFAULT_PREALLOCATION, factoriesBuilder, nameFields inherited from interface org.elasticsearch.index.query.RewriteableMAX_REWRITE_ROUNDSFields inherited from interface org.elasticsearch.xcontent.ToXContentEMPTY_PARAMS
- 
Constructor SummaryConstructorsModifierConstructorDescriptionCreate a new builder with the given name.Read from a stream, for internal use only.protectedDateHistogramAggregationBuilder(DateHistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) 
- 
Method SummaryModifier and TypeMethodDescriptionA rough count of the number of buckets thatAggregators built by this builder will contain per owning parent bucket.calendarInterval(DateHistogramInterval interval) Sets the interval of the DateHistogram using calendar units (`1d`, `1w`, `1M`, etc).protected ValuesSourceTypeAggregations should use this method to define aValuesSourceTypeof last resort.protected XContentBuilderdoXContentBody(XContentBuilder builder, ToXContent.Params params) booleanReturn extended bounds for this histogram, ornullif none are set.extendedBounds(LongBounds extendedBounds) Set extended bounds on this histogram, so that buckets would also be generated on intervals that did not match any documents.fixedInterval(DateHistogramInterval interval) Sets the interval of the DateHistogram using fixed units (`1ms`, `1s`, `10m`, `4h`, etc).Returns the interval as a date time unit if and only if it was configured as a calendar interval originally.Returns the interval as a fixed time unit if and only if it was configured as a fixed interval originally.The minimal version of the recipient this object can be sent toprotected ValuesSourceRegistry.RegistryKey<?>getType()The name of the type of aggregation built by this builder.Return hard bounds for this histogram, ornullif none are set.hardBounds(LongBounds hardBounds) Set hard bounds on this histogram, specifying boundaries outside which buckets cannot be created.inthashCode()protected ValuesSourceAggregatorFactoryinnerBuild(AggregationContext context, ValuesSourceConfig config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) protected voidinnerWriteTo(StreamOutput out) Write subclass's state to the stream.booleankeyed()Return whether buckets should be returned as a hash.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.longReturn the minimum count of documents that buckets need to have in order to be included in the response.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.longoffset()Get the offset to use when rounding, which is a number of milliseconds.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.Set the offset on this builder, as a time value, and return the builder so that calls can be chained.order()Return the order to use to sort buckets of this histogram.order(List<BucketOrder> orders) Sets the order in which the buckets will be returned.order(BucketOrder order) Set a new order on this builder and return the builder so that calls can be chained.static longparseStringOffset(String offset) Parse the string specification of an offset.static voidprotected AggregationBuildershallowCopy(AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) Create a shallow copy of this builder and replacingAggregationBuilder.factoriesBuilderandmetadata.booleanDoes this aggregation support running with in a sampling context.protected voidvalidateSequentiallyOrdered(String type, String name, Consumer<String> addValidationError) Called by aggregations whose parents must be sequentially ordered.protected voidvalidateSequentiallyOrderedWithoutGaps(String type, String name, Consumer<String> addValidationError) Called by aggregations whose parents must be sequentially ordered without any gaps.Methods inherited from class org.elasticsearch.search.aggregations.support.ValuesSourceAggregationBuilderdeclareFields, declareFields, doBuild, doWriteTo, field, field, format, format, internalXContent, missing, missing, resolveConfig, script, script, serializeTargetValueType, timeZone, timeZone, userValueTypeHint, userValueTypeHintMethods inherited from class org.elasticsearch.search.aggregations.AbstractAggregationBuilderbuild, getMetadata, getWriteableName, setMetadata, subAggregation, subAggregation, subAggregations, toXContent, writeToMethods inherited from class org.elasticsearch.search.aggregations.AggregationBuilderbuildPipelineTree, bytesToPreallocate, doRewrite, getName, getOutputFieldNames, getPipelineAggregations, getSubAggregations, isInSortOrderExecutionRequired, rewrite, toStringMethods inherited from class java.lang.Objectclone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.xcontent.ToXContentFragmentisFragment
- 
Field Details- 
NAME- See Also:
 
- 
REGISTRY_KEY
- 
DATE_FIELD_UNITS
- 
PARSER
 
- 
- 
Constructor Details- 
DateHistogramAggregationBuilderCreate a new builder with the given name.
- 
DateHistogramAggregationBuilderprotected DateHistogramAggregationBuilder(DateHistogramAggregationBuilder clone, AggregatorFactories.Builder factoriesBuilder, Map<String, Object> metadata) 
- 
DateHistogramAggregationBuilderRead from a stream, for internal use only.- Throws:
- IOException
 
 
- 
- 
Method Details- 
registerAggregators
- 
shallowCopyprotected 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 class- AggregationBuilder
 
- 
supportsSamplingpublic boolean supportsSampling()Description copied from class:AggregationBuilderDoes this aggregation support running with in a sampling context. By default, it's false for all aggregations. If the sub-classed builder supports sampling, be sure of the following that the resulting internal aggregation objects override theInternalAggregation.finalizeSampling(SamplingContext)and scales any values that require scaling.- Overrides:
- supportsSamplingin class- AggregationBuilder
- Returns:
- does this aggregation builder support sampling
 
- 
defaultValueSourceTypeDescription copied from class:ValuesSourceAggregationBuilderAggregations should use this method to define aValuesSourceTypeof last resort. This will only be used when the resolver can't find a field and the user hasn't provided a value type hint.- Specified by:
- defaultValueSourceTypein class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
- Returns:
- The CoreValuesSourceType we expect this script to yield.
 
- 
innerWriteToDescription copied from class:ValuesSourceAggregationBuilderWrite subclass's state to the stream.- Specified by:
- innerWriteToin class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
- Throws:
- IOException
 
- 
calendarIntervalSets 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 interface- DateIntervalConsumer<DateHistogramAggregationBuilder>
- Parameters:
- interval- The calendar interval to use with the aggregation
 
- 
fixedIntervalSets 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 interface- DateIntervalConsumer<DateHistogramAggregationBuilder>
- Parameters:
- interval- The fixed interval to use with the aggregation
 
- 
getCalendarIntervalReturns the interval as a date time unit if and only if it was configured as a calendar interval originally. Returns null otherwise.
- 
getFixedIntervalReturns the interval as a fixed time unit if and only if it was configured as a fixed interval originally. Returns null otherwise.
- 
offsetpublic long offset()Get the offset to use when rounding, which is a number of milliseconds.
- 
offsetSet the offset on this builder, which is a number of milliseconds, and return the builder so that calls can be chained.
- 
offsetSet the offset on this builder, as a time value, and return the builder so that calls can be chained.
- 
parseStringOffsetParse the string specification of an offset.
- 
extendedBoundsReturn extended bounds for this histogram, ornullif none are set.
- 
extendedBoundsSet extended bounds on this histogram, so that buckets would also be generated on intervals that did not match any documents.
- 
hardBoundsReturn hard bounds for this histogram, ornullif none are set.
- 
hardBoundsSet hard bounds on this histogram, specifying boundaries outside which buckets cannot be created.
- 
orderReturn the order to use to sort buckets of this histogram.
- 
orderSet 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.
- 
orderSets the order in which the buckets will be returned. A tie-breaker may be added to avoid non-deterministic ordering.
- 
keyedpublic boolean keyed()Return whether buckets should be returned as a hash. In casekeyedis false, buckets will be returned as an array.
- 
keyedSet whether to return buckets as a hash or as an array, and return the builder so that calls can be chained.
- 
minDocCountpublic long minDocCount()Return the minimum count of documents that buckets need to have in order to be included in the response.
- 
minDocCountSet the minimum count of matching documents that buckets need to have and return this builder so that calls can be chained.
- 
bucketCardinalityDescription copied from class:AggregationBuilderA rough count of the number of buckets thatAggregators built by this builder will contain per owning parent bucket.- Specified by:
- bucketCardinalityin class- AggregationBuilder
 
- 
doXContentBodyprotected XContentBuilder doXContentBody(XContentBuilder builder, ToXContent.Params params) throws IOException - Specified by:
- doXContentBodyin class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
- Throws:
- IOException
 
- 
getTypeDescription copied from interface:BaseAggregationBuilderThe name of the type of aggregation built by this builder.- Specified by:
- getTypein interface- BaseAggregationBuilder
 
- 
getRegistryKey- Specified by:
- getRegistryKeyin class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
 
- 
innerBuildprotected ValuesSourceAggregatorFactory innerBuild(AggregationContext context, ValuesSourceConfig config, AggregatorFactory parent, AggregatorFactories.Builder subFactoriesBuilder) throws IOException - Specified by:
- innerBuildin class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
- Throws:
- IOException
 
- 
hashCodepublic int hashCode()- Overrides:
- hashCodein class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
 
- 
equals- Overrides:
- equalsin class- ValuesSourceAggregationBuilder<DateHistogramAggregationBuilder>
 
- 
getMinimalSupportedVersionDescription copied from interface:VersionedNamedWriteableThe minimal version of the recipient this object can be sent to- Specified by:
- getMinimalSupportedVersionin interface- VersionedNamedWriteable
 
- 
validateSequentiallyOrderedprotected void validateSequentiallyOrdered(String type, String name, Consumer<String> addValidationError) Description copied from class:AggregationBuilderCalled by aggregations whose parents must be sequentially ordered.- Overrides:
- validateSequentiallyOrderedin class- AggregationBuilder
- Parameters:
- type- the type of the aggregation being validated
- name- the name of the aggregation being validated
- addValidationError- callback to add validation errors
 
- 
validateSequentiallyOrderedWithoutGapsprotected void validateSequentiallyOrderedWithoutGaps(String type, String name, Consumer<String> addValidationError) Description copied from class:AggregationBuilderCalled by aggregations whose parents must be sequentially ordered without any gaps.- Overrides:
- validateSequentiallyOrderedWithoutGapsin class- AggregationBuilder
- Parameters:
- type- the type of the aggregation being validated
- name- the name of the aggregation being validated
- addValidationError- callback to add validation errors
 
 
-