ES 5.2 - DateHistogram聚合查询问题,时间戳字段为长类型

时间:2017-03-22 07:13:01

标签: elasticsearch

我们正面临一个与直方图聚合相关的问题,同时从2.2升级到5.2。我们将时间戳字段存储为“长”数据类型

DateHistogram聚合查询

"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.

Is there any other way for histogram aggregation query to work without changing data type of field ?

0 个答案:

没有答案