简体   繁体   中英

Elasticsearch: date_histogram with 5y interval

How to make Elasticsearch date_histogram work like this:

{
  "aggs": {
    "age_range": {
      "date_histogram": {
        "field": "birthdate",
        "interval": "5y"
      }
    }
  }
}

This is a known issue in elasticsearch, you can use either 260 weeks(260w) or 1825 days(1825d) (you can consider leap year if you want).

This will work

{
  "size": 0,
  "aggs": {
    "NAME": {
      "date_histogram": {
        "field": "birthdate",
        "interval": "1825d"

      }
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM