How i can use **bool query** in **post_filter**

I I tried this search but not working

GET ecommerce/products/_search
{
  "size": 0, 
  "aggs": {
    "all_color": {
      "terms": {
        "field": "color.keyword"
      }
    }
  },
  "post_filter": {
    "query": {
      "bool": {
        "must": [
          {
            "term": {
              "name.keyword": {
                "value": "robe"
              }
            }
          }
        ]
      }
    }
  }
}

But i received this error

{
  "error": {
    "root_cause": [
      {
        "type": "parsing_exception",
        "reason": "no [query] registered for [query]",
        "line": 11,
        "col": 14
      }
    ],
    "type": "parsing_exception",
    "reason": "no [query] registered for [query]",
    "line": 11,
    "col": 14
  },
  "status": 400
}

Try

GET ecommerce/products/_search
{
  "size": 0, 
  "aggs": {
    "all_color": {
      "terms": {
        "field": "color.keyword"
      }
    }
  },
  "post_filter": {
      "bool": {
        "must": [
          {
            "term": {
              "name.keyword": {
                "value": "robe"
              }
            }
          }
        ]
      }
  }
}
1 Like

Thanks !
Problem is solved :grinning:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.