Confusing DateHistogram behavior: buckets starts not from min bound date

I'd already create bug-report
But maybe someone already know that issue workarounds.
Merge days by 7days intervals in code is the last thing I want to do. But still doesn't find any other solution.

1 Like

The intervals are computed based on 1970-01-01 as the first bucket. This makes the bucketing consistent for the same interval. If you want to change this behavior you can use the offset option:
https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-datehistogram-aggregation.html#_offset
... or set the interval to week.
The extended bounds are treated as if they were values from existing documents and not as already existing buckets.

1 Like

Which offset value I should use to have date of first bucket equals to start date of my interval?

If I use offset "+2d" for this example first bucket starts from 30 Nov 2017 but second starts from 02 Dec as expected and other next in 7 days.

If second bucket doesn't have any data offset doesn't work at all

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.