elasticsearch/elasticsearch — Issue #1580: Date Histogram Facet: Improve time zone handling, add factor option
Author: kimchy
Created: 2011-12-31 22:09:31+00:00
State: open
Labels: breaking, bug, enhancement, v0.19.0

The current date histogram handling is incorrect when it comes to handing timezone. It applies the time zone when doing day level resolution and above (but still return the milliseconds offseted by "-" instead of "+"), and below it won't allow to get back the results based on a specific time zone. So, the logic changed a bit (and defaults):

A new `pre_zone` and `post_zone` parameters allowed, but default to `UTC`. When setting the current `time_zone`, it will set `pre_zone`. (backward comp. change!). The idea is that the value stored in ES (milliseconds since epoch in UTC) is applied the `pre_zone`, rounded, and then applied `post_zone`.

The new `factor` parameter allows to use date histogram on long fields that store different resolution than milliseconds. For example, a field that stores seconds since epoch can pass a factor of 1000 which will allow to still use the date histogram.