ES 5.2 Histogram aggregration query issue with timestamp field as long type


We are facing one issue related to histogram aggregation while upgrading from 2.2 to 5.2.
We are storing timestamp field with "mapping": {"type": "long","store": "yes"}

And using below histogram aggregation query
"aggregations" : {
"datehistogram" : {
"date_histogram" : {
"field" : "timestamp",
"time_zone" : "+05:30",
"interval" : "minute",
"offset" : 0,
"order" : {
"_key" : "asc"
"keyed" : false,
"min_doc_count" : 0

This query was working well with ES 2.2 version. But with ES 5.2 its throwing below error

Caused by: java.lang.IllegalArgumentException: Field [timestamp] of type [long] does not support custom time zones
at org.elasticsearch.index.mapper.NumberFieldMapper$NumberFieldType.docValueFormat( ~[elasticsearch-5.2.2.jar:5.2.2].

By changing type of timestamp field from 'long' to 'date' aggregation query works well.
But it will require re-indexing of old data and we are looking option to avoid it.

One alternate option we can think of is passing time range adjusted with timezone, basically above query without time_zone attribute, but not sure
implications of it. Please share your views on this approach.

Also kindly suggest is there any other way for histogram aggregation query to work without changing data type of field ?

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