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

**URL:** https://discuss.elastic.co/t/es-5-2-histogram-aggregration-query-issue-with-timestamp-field-as-long-type/79354
**Category:** Elasticsearch
**Created:** [March 21, 2017, 6:28am UTC](https://discuss.elastic.co/t/es-5-2-histogram-aggregration-query-issue-with-timestamp-field-as-long-type/79354 "2017-03-21T06:28:01Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![nrmohta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nrmohta/32/120038_2.png) [@nrmohta](https://discuss.elastic.co/u/nrmohta)
#### Post date: [March 21, 2017, 6:28am UTC](https://discuss.elastic.co/t/es-5-2-histogram-aggregration-query-issue-with-timestamp-field-as-long-type/79354/1 "2017-03-21T06:28:01Z")

</div>

Team,

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(NumberFieldMapper.java:953) ~[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 ?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 18, 2017, 6:28am UTC](https://discuss.elastic.co/t/es-5-2-histogram-aggregration-query-issue-with-timestamp-field-as-long-type/79354/2 "2017-04-18T06:28:26Z")

</div>

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