查询正文:
{
"query": {
"script": {
"script": {
"lang": "painless",
"inline": "doc['TIME'].date.getHourOfDay() > 8 && doc['TIME'].date.getHourOfDay() <= 9",
"params": {
"startHour": 8,
"endHour": 9
}
}
}
},
"size": 1
}
我可以从es5.0获取查询结果。 但是当我使用params替换数字(8和9)时,例如:
"inline": "doc['TIME'].date.getHourOfDay() > startHour &&
doc['TIME'].date.getHourOfDay() <= endHour",
"params": {
"startHour": 8,
"endHour": 9
}
...
ES返回如下错误:
"caused_by": {
"type": "script_exception",
"reason": "compile error",
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Variable [startHour] is not defined."
},
...
问题是什么?