错误:[bool]查询不支持[term]

Ros*_*ose 4 elasticsearch

我使用的是Elasticsearch版本2.3.2.我试图在布尔查询上使用过滤器,但我收到一个错误:

"type": "query_parsing_exception",
            "reason": "[bool] query does not support [term]",
Run Code Online (Sandbox Code Playgroud)

我的elasticsearch查询是:

GET index_name/_search
{
  "query": {
    "bool": {
      "must": [
        {"match": {
          "title": "white"
        }},
        {
          "match": {
            "newContent": "white"
          }
        }
      ],
      "filter": {
        "term": {
          "default_collection": "true"
        }
      }
      ,"term":{
        "wiki_collection": "true"
      }
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我不确定问题是什么.我可能会遗漏一些东西

Val*_*Val 8

您需要termfilter数组中移动两个过滤器(并在发送有效负载时使用POST而不是GET):

POST index_name/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "title": "white"
          }
        },
        {
          "match": {
            "newContent": "white"
          }
        }
      ],
      "filter": [
        {
          "term": {
            "default_collection": "true"
          }
        },
        {
          "term": {
            "wiki_collection": "true"
          }
        }
      ]
    }
  }
}
Run Code Online (Sandbox Code Playgroud)