我使用 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
调整时区,一切都很好。但是如果我尝试动态调整时区,一切都会失败。有什么帮助吗?