Class DateIntervalWrapper
java.lang.Object
org.elasticsearch.search.aggregations.bucket.histogram.DateIntervalWrapper
- All Implemented Interfaces:
Writeable
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentFragment
public class DateIntervalWrapper
extends Object
implements org.elasticsearch.common.xcontent.ToXContentFragment, Writeable
A class that handles all the parsing, bwc and deprecations surrounding date histogram intervals.
- Provides parser helpers for the new calendar/fixed interval parameters
- Can write new intervals to old format when streaming out
- Provides a variety of helper methods to interpret the intervals as different types, depending on caller's need
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
calendarInterval(DateHistogramInterval interval)
Sets the interval of the DateHistogram using calendar units (`1d`, `1w`, `1M`, etc).createRounding(ZoneId timeZone, long offset)
static <T extends DateIntervalConsumer<T>>
voiddeclareIntervalFields(org.elasticsearch.common.xcontent.ObjectParser<T,String> parser)
boolean
void
fixedInterval(DateHistogramInterval interval)
Sets the interval of the DateHistogram using fixed units (`1ms`, `1s`, `10m`, `4h`, etc).Returns the interval as a calendar interval.Returns the interval as a Fixed interval.int
hashCode()
boolean
isEmpty()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ToXContentFragment
isFragment
-
Constructor Details
-
DateIntervalWrapper
public DateIntervalWrapper() -
DateIntervalWrapper
- Throws:
IOException
-
-
Method Details
-
declareIntervalFields
public static <T extends DateIntervalConsumer<T>> void declareIntervalFields(org.elasticsearch.common.xcontent.ObjectParser<T,String> parser) -
getIntervalType
-
getAsCalendarInterval
Returns the interval as a calendar interval. Throws an exception if the value cannot be converted into a calendar interval -
calendarInterval
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)
- Parameters:
interval
- The fixed interval to use
-
getAsFixedInterval
Returns the interval as a Fixed interval. Throws an exception if the value cannot be converted into a fixed interval -
fixedInterval
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)
- Parameters:
interval
- The fixed interval to use
-
createRounding
-
isEmpty
public boolean isEmpty() -
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
IOException
-
equals
-
hashCode
public int hashCode()
-