Skip to content

Document date aggregation limitation on arbitrary time intervals #23294

@ppf2

Description

@ppf2

As part of #19649 and #8939, it is revealed that date histogram does not support arbitrary time intervals, eg. 2M (for 2 months), etc.. for larger time spans like months, years, and weeks (on 5.0+).

  1. Our documentation today (https://www.elastic.co/guide/en/elasticsearch/reference/master/search-aggregations-bucket-datehistogram-aggregation.html) is not clear on this limitation today. It suggests that only fractional units are not supported.

Available expressions for interval: year, quarter, month, week, day, hour, minute, second
Time values can also be specified via abbreviations supported by time units parsing. Note that fractional time values are not supported, but you can address this by shifting to another time unit (e.g., 1.5h could instead be specified as 90m).

  1. From the discussion in date_histogram fails for year buckets >1, like "10y" #8939, it sounds like weeks is supported for arbitrary units (and it does work on pre-5.0 versions from testing 2.3, etc..). But on 5.0+, it now throws:
{
  "error": {
    "root_cause": [
      {
        "type": "parse_exception",
        "reason": "failed to parse setting [DateHistogramAggregationBuilder.interval] with value [2w] as a time value: unit is missing or unrecognized"
      }
    ],

This is an intended change as well per Colin, so let's document that all interval types with time spans (week, month, year) longer than days do not support arbitrary intervals.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions