[simple_query_string]中START_OBJECT的未知密钥

时间:2017-10-16 13:48:16

标签: elasticsearch

在elasticsearch 5.6.2和5.6.3(Ubuntu 16.04)中,这个查询

GET _search
{
   "simple_query_string": {
      "query": "test1 + test2",
      "analyzer": "snowball",
      "fields": ["myfield"],
      "default_operator": "and"
   }
}

导致此错误

{
   "error": {
      "root_cause": [
         {
            "type": "parsing_exception",
            "reason": "Unknown key for a START_OBJECT in [simple_query_string].",
            "line": 2,
            "col": 44
         }
      ],
      "type": "parsing_exception",
      "reason": "Unknown key for a START_OBJECT in [simple_query_string].",
      "line": 2,
      "col": 44
   },
   "status": 400
}

这与此处的第一个示例https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-simple-query-string-query.html

几乎相同

有人能帮助我吗?

1 个答案:

答案 0 :(得分:4)

您需要在simple_query_string部分中加入query,如下所示:

GET _search
{
  "query": {
    "simple_query_string": {
      "query": "test1 + test2",
      "analyzer": "snowball",
      "fields": ["myfield"],
      "default_operator": "and"
    }
  }
}