# Using must query in filter section of DSl elastic

**URL:** <https://discuss.elastic.co/t/using-must-query-in-filter-section-of-dsl-elastic/349953>\
**Category:** Elasticsearch\
**Created:** [December 26, 2023, 12:01pm UTC](https://discuss.elastic.co/t/using-must-query-in-filter-section-of-dsl-elastic/349953 "2023-12-26T12:01:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aniket\_Pant](https://avatars.discourse-cdn.com/v4/letter/a/77aa72/32.png) [@Aniket\_Pant](https://discuss.elastic.co/u/Aniket_Pant)\
**Post date:** [December 26, 2023, 12:01pm UTC](https://discuss.elastic.co/t/using-must-query-in-filter-section-of-dsl-elastic/349953/1 "2023-12-26T12:01:16Z")

</div>

```auto
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"
              }
            }
          }
          ]
        }
      ]
    }
  }
}

```

```auto
"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.

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [December 26, 2023, 12:20pm UTC](https://discuss.elastic.co/t/using-must-query-in-filter-section-of-dsl-elastic/349953/2 "2023-12-26T12:20:25Z")

</div>

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](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-bool-query.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 23, 2024, 12:21pm UTC](https://discuss.elastic.co/t/using-must-query-in-filter-section-of-dsl-elastic/349953/3 "2024-01-23T12:21:07Z")

</div>

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