Error : [bool] query does not support [term]

12,768

You need to move both term filters inside a filter array (and use POST instead of GET when sending a payload):

POST index_name/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "title": "white"
          }
        },
        {
          "match": {
            "newContent": "white"
          }
        }
      ],
      "filter": [
        {
          "term": {
            "default_collection": "true"
          }
        },
        {
          "term": {
            "wiki_collection": "true"
          }
        }
      ]
    }
  }
}
Share:
12,768
Rose
Author by

Rose

Write code for a living

Updated on July 07, 2022

Comments

  • Rose
    Rose almost 2 years

    I am using Elasticsearch version 2.3.2. I am trying to use filter on boolean query, but I am getting an error:

    "type": "query_parsing_exception",
                "reason": "[bool] query does not support [term]",
    

    My elasticsearch query is:

    GET index_name/_search
    {
      "query": {
        "bool": {
          "must": [
            {"match": {
              "title": "white"
            }},
            {
              "match": {
                "newContent": "white"
              }
            }
          ],
          "filter": {
            "term": {
              "default_collection": "true"
            }
          }
          ,"term":{
            "wiki_collection": "true"
          }
        }
      }
    }
    

    I am not sure what the problem is. I might be missing something