liveBook · Manning

Fixed interval

As explained in Elasticsearch in Action, Second Edition

A fixed interval is a date histogram interval represented by a constant number of time units without calendar-aware month or year semantics.

A fixed interval groups date values into equal durations measured in constant time units. Unlike a calendar interval, it does not adjust for calendar settings and cannot represent months, quarters, or years directly. section 13.3.1

Use fixed intervals when calendar-aware boundaries are unnecessary:

  • Choose days, hours, minutes, seconds, or milliseconds. section 13.3.1
  • Express a duration with a number and unit, such as 730d or 12h. section 13.3.1
  • Use calendar_interval instead when month, quarter, year, or calendar-adjusted boundaries matter. section 13.3.1
Listing 13.12 Histogram with a fixed interval of 2 years (730 days)
GET books/_search
{
  "size":0,
  "aggs": {
    "release_date_histogram": {
      "date_histogram": {
        "field": "release_date",
        "fixed_interval": "730d"     #1
      }
    }
  }
}

A date histogram groups book release dates into fixed 730-day buckets. section 13.3.1

How Elasticsearch in Action, Second Edition covers it

How deep it goes
Defines the distinction, supported units, syntax, and a 730-day query, but does not detail bucket-boundary computation.
Examples
Uses book release dates grouped with a fixed_interval of 730d.
What it assumes
Assumes a date_histogram aggregation and a date field such as release_date.
What you can do after
Apply it via a date_histogram aggregation using constant day, hour, minute, second, or millisecond durations.
How it connects
Links date_histogram, calendar_interval, and histogram aggregations.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elasticsearch in Action, Second Edition. The section links point to the parts of the book it draws on.