elasticsearch:无痛脚本params错误

时间:2017-06-13 08:34:15

标签: elasticsearch

查询正文:

{
    "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."
          }, 

...

问题是什么?

0 个答案:

没有答案