【发布时间】:2017-07-31 02:43:26
【问题描述】:
我使用 ES 5.1.2,我试图从 date 字段计算星期几和一天中的时间,同时考虑时区。
我的第一个脚本是def d = doc['my_field'].date; d.addHours(10); d.getDayOfWeek();
错误信息是找不到 addHours() 方法
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Unable to find dynamic method [addHours] with [1] arguments for class [org.joda.time.MutableDateTime]."
},
"script_stack": [
"d.addHours(10); ",
" ^---- HERE"
],
如果我把脚本改成MutableDateTime d = doc['my_field'].date; d.addHours(10); d.getDayOfWeek(); 错误信息就变成了
"caused_by": {
"type": "illegal_argument_exception",
"reason": "unexpected token ['d'] was expecting one of [{<EOF>, ';'}]."
},
"script_stack": [
"MutableDateTime d = doc['relation_denstu. ...",
" ^---- HERE"
],
没有addHours 调整时区,一切都很好。但是如果我尝试动态调整时区,一切都会失败。有什么帮助吗?
【问题讨论】:
标签: elasticsearch elasticsearch-5 elasticsearch-painless