从5.6.9滚动升级到6.8.13遇到的问题, Cannot apply [>] operation

今天升级公司的es版本,从5.6.9滚动升级到6.8.13,升级过程一切顺利,个别业务检索有异常。

下面是dsl片段:

Dsl:

script" : {

      "source" : "double score = doc['score'].value + 1;if(!doc['endTime'].empty && doc['endTime'].value > params.endTime){score *= 2.5;} if(!doc['endTime'].empty && doc['endTime'].value < params.endTime){score *= 0.5;} return score;",

报:

Cannot apply [>] operation to types [org.elasticsearch.script.JodaCompatibleZonedDateTime] and [java.lang.Long].]

 

经过查询,6.1版本就已经移除了这个功能

Comparison (<) not supported on datetime fields anymore since upgrade to 6.1

需要对时间进行转换:

doc['endTime'].value.toInstant().toEpochMilli() > params.endTime

 

posted @ 2021-02-26 22:27  嘉美祥瑞  阅读(837)  评论(0编辑  收藏  举报