Class DateIntervalWrapper

java.lang.Object
org.elasticsearch.search.aggregations.bucket.histogram.DateIntervalWrapper
All Implemented Interfaces:
Writeable, org.elasticsearch.xcontent.ToXContent, org.elasticsearch.xcontent.ToXContentFragment

public class DateIntervalWrapper extends Object implements org.elasticsearch.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
  • Constructor Details

  • Method Details

    • declareIntervalFields

      public static <T extends DateIntervalConsumer<T>> void declareIntervalFields(org.elasticsearch.xcontent.ObjectParser<T,String> parser)
    • getIntervalType

      public DateIntervalWrapper.IntervalTypeEnum getIntervalType()
    • getAsCalendarInterval

      public DateHistogramInterval getAsCalendarInterval()
      Returns the interval as a calendar interval. Throws an exception if the value cannot be converted into a calendar interval
    • calendarInterval

      public void 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 with fixedInterval(DateHistogramInterval)
      Parameters:
      interval - The fixed interval to use
    • getAsFixedInterval

      public DateHistogramInterval getAsFixedInterval()
      Returns the interval as a Fixed interval. Throws an exception if the value cannot be converted into a fixed interval
    • fixedInterval

      public void 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 with calendarInterval(DateHistogramInterval)
      Parameters:
      interval - The fixed interval to use
    • createRounding

      public Rounding createRounding(ZoneId timeZone, long offset)
    • isEmpty

      public boolean isEmpty()
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • toXContent

      public org.elasticsearch.xcontent.XContentBuilder toXContent(org.elasticsearch.xcontent.XContentBuilder builder, org.elasticsearch.xcontent.ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface org.elasticsearch.xcontent.ToXContent
      Throws:
      IOException
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object