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

Nested Query Compatibility in Elastic Search 5.6

我的 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 中不起作用吗??

在ES 5.6.7中你需要这样写:

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

查找文档 here