Date Histogram Aggregation - decade interval

Can anybody explain how and if it is possible to build a decade interval with date histogram aggregation?

I tried interval 10y which isn't supported. As possible solution used 3650d as interval which seems to work but not completely.

Here is my agg:

"decades": {
       "date_histogram": {
         "field": "bc_dat",
         "interval": "3650d",
         "format": "dd.MM.yyyy"
       }
 }

and here are some results:

  "decades": {
     "buckets": [
        {
           "key_as_string": "06.01.1950",
           "key": -630720000000,
           "doc_count": 20
        },
        {
           "key_as_string": "04.01.1960",
           "key": -315360000000,
           "doc_count": 100
        },
        {
           "key_as_string": "01.01.1970",
           "key": 0,
           "doc_count": 166
        },
        {
           "key_as_string": "30.12.1979",
           "key": 315360000000,
           "doc_count": 547
        },
        {
           "key_as_string": "27.12.1989",
           "key": 630720000000,
           "doc_count": 669
        },
        {
           "key_as_string": "25.12.1999",
           "key": 946080000000,
           "doc_count": 842
        },
        {
           "key_as_string": "22.12.2009",
           "key": 1261440000000,
           "doc_count": 108
        }
     ]
  }

as you can see it works until 01.01.1970 but afterwards ist gets e.g. 1979 and 1989 instead of 1980 and 1990. Any ideas how to solve this?

It's sadly not doable ATM: https://github.com/elastic/elasticsearch/issues/8939

What I'm doing in that case is doing that on the client side. So I build aggs per year and aggregate on client.
Works well but if you need to have sub aggs that becomes tricky...

1 Like

:pensive:

anyway thank's for your fast response