Elastic Search 5.6中的嵌套查询兼容性

时间:2018-12-17 07:24:18

标签: elasticsearch querydsl

我的REST调用(POST)中的有效负载低于其有效工作的Elastic search 2.1.1,但在ES 5.6.7中则没有

{"from":0,"size":5,"sort":[{"releasedDate":{"order":"desc"}}],"query":{"query_string":{"query":{"query":"demo demo*","defaultOperator":"and"}}}}

在ES 5.6.7中,我遇到了异常

{
"error": {
    "root_cause": [
        {
            "type": "parsing_exception",
            "reason": "[query_string] unknown token [START_OBJECT] after [query]",
            "line": 1,
            "col": 96
        }
    ],
    "type": "parsing_exception",
    "reason": "[query_string] unknown token [START_OBJECT] after [query]",
    "line": 1,
    "col": 96
},
"status": 400

}

任何人都知道为什么有效负载无法在ES 5.6.7中工作?

1 个答案:

答案 0 :(得分:2)

在ES 5.6.7中,您需要这样编写:

{
  "from": 0,
  "size": 5,
  "sort": [
    {
      "releasedDate": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "query_string": {
      "query": "demo demo*",
      "default_operator": "and"
    }
  }
}

找到文档here