ElasticSearch 1.5升级:JodaTime转换脚本错误

ElasticSearch 1.5 upgrade: JodaTime conversion script error

我正在努力将我们的 ElasticSearch 版本从 1.3 升级到 1.5。我们大量使用 Java API。 ES 查询中的以下脚本:

 {
  "script" : {
    "script" : "values contains (int)doc['timestamp'].date.toDateTime(DateTimeZone.forID('America/New_York')).getMonthOfYear()",
    "params" : {
      "values" : [ 1 ]
    },
    "lang" : "groovy"
  }
}

这适用于 1.3,但在 1.5 中会出现以下错误:

org.elasticsearch.action.search.SearchPhaseExecutionException: Failed to execute phase [query_fetch], all shards failed; shardFailures {[XwOu9zq0TMi2uOptdfIS7w][eventdata][0]: QueryPhaseExecutionException[[eventdata][0]: query[filtered(ConstantScore(ScriptFilter(values contains (int)doc['timestamp'].date.toDateTime(DateTimeZone.forID('America/New_York')).getMonthOfYear().toString())))->cache(org.elasticsearch.index.search.nested.NonNestedDocsFilter@2a8c0465)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: GroovyScriptExecutionException[MissingMethodException[No signature of method: Script1.contains() is applicable for argument types: (java.lang.Class) values: [int]
Possible solutions: toString(), toString(), notify()]]; }
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFirstPhaseResult(TransportSearchTypeAction.java:238)
    at org.elasticsearch.action.search.type.TransportSearchTypeAction$BaseAsyncAction.onFailure(TransportSearchTypeAction.java:184)
    at org.elasticsearch.search.action.SearchServiceTransportAction.run(SearchServiceTransportAction.java:565)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)

解决这个问题的最佳方法是什么?

这看起来像是演员表的括号问题,因此它认为您正在将 int 传递给 contains。尝试添加括号来帮助解析器:

values.contains((int)doc['timestamp'].date.toDateTime(DateTimeZone.forID('Ameri‌​ca/New_York')).getMonthOfYear())