# Bool Filter doubt / Match\_all

**URL:** <https://discuss.elastic.co/t/bool-filter-doubt-match-all/335982>\
**Category:** Elasticsearch\
**Created:** [June 14, 2023, 1:19pm UTC](https://discuss.elastic.co/t/bool-filter-doubt-match-all/335982 "2023-06-14T13:19:32Z")\
**Posts on this page:** 2\
**Page:** 1

<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:** [June 14, 2023, 1:19pm UTC](https://discuss.elastic.co/t/bool-filter-doubt-match-all/335982/1 "2023-06-14T13:19:32Z")

</div>

Hi everybody.

Maybe this is a silly doubt but if someone can answer.

I have 3 docs, 1 with status:true field, 1 with status:false field and 1 doc without status field.

```auto
POST idx_test/_bulk
{"index":{}}
{"name":"xpto 1", "status": true}
{"index":{}}
{"name":"xpto 2", "status": false}
{"index":{}}
{"name":"xpto 3"}

```

I want to use a bool-filter to retrieve all 3 documents. I'm in doubt if I should use match\_all inside the bool-filter or a should. Which of these two would be the best option looking at performance?

Filter with match all:

```auto
GET idx_test/_search
{
  "query": {
    "bool": {
      "filter": [
        {
          "match_all": {
          }
        }
      ]
    }
  }
}

```

Filter + should

```auto
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "minimum_should_match": 1,
            "should": [
              {
                "bool": {
                  "must_not": [
                    {
                      "exists": {
                        "field": "status"
                      }
                    }
                  ]
                }
              },
              {
                "term": {
                  "status": {
                    "value": false
                  }
                }
              },
              {
                "term": {
                  "status": {
                    "value": true
                  }
                }
              }
            ]
          }
        }
      ]
    }
  }
}

```

---

<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:** [July 12, 2023, 1:19pm UTC](https://discuss.elastic.co/t/bool-filter-doubt-match-all/335982/2 "2023-07-12T13:19:49Z")

</div>

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