Using must query in filter section of DSl elastic

GET rds_database-*/_search
{
  "_source": ["failure_error_text"],
  "query": {
    "bool": {
      "filter": [
        {
          "must":[
          {
            "term":{
              "status.keyword":"F"
            },
            "range":
            {
              "@timestamp":
              {
                "gte":"now-1y/d",
                "lte":"now/d"
              }
            }
          }
          ]
        }
      ]
    }
  }
}
"type": "x_content_parse_exception",
    "reason": "[7:18] [bool] failed to parse field [filter]",
    "caused_by": {
      "type": "parsing_exception",
      "reason": "[must] query malformed, no start_object after query name",
      "line": 7,
      "col": 18
    }

I want to use must query in filter clause . I don't know where i am doing wrong.

Hi @Aniket_Pant

If you really need must inside filter you need put a new bool clause after filter and the must clause inside the second bool.

Doc: Boolean query | Elasticsearch Guide [8.11] | Elastic

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