Confusing DateHistogram behavior: buckets starts not from min bound date


(Guchman) #1

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.


DateHistogram offset does not work when empty buckets
(Jimferenczi) #2

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.


(Паша Варченко) #3

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


(Паша Варченко) #4

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.


(Паша Варченко) #5

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


(system) #6

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