# Why do I have wrap "filter" inside "bool" when I'm only filtering for a single field?

**URL:** <https://discuss.elastic.co/t/why-do-i-have-wrap-filter-inside-bool-when-im-only-filtering-for-a-single-field/308306>\
**Category:** Elasticsearch\
**Created:** [June 28, 2022, 2:22am UTC](https://discuss.elastic.co/t/why-do-i-have-wrap-filter-inside-bool-when-im-only-filtering-for-a-single-field/308306 "2022-06-28T02:22:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thomas708](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@thomas708](https://discuss.elastic.co/u/thomas708)\
**Post date:** [June 28, 2022, 2:22am UTC](https://discuss.elastic.co/t/why-do-i-have-wrap-filter-inside-bool-when-im-only-filtering-for-a-single-field/308306/1 "2022-06-28T02:22:35Z")

</div>

In ElasticSearch 7.10 this query works

```auto
{
    "query": {
        "bool": {
            "filter": {
                "term": {
                    "field1": "value1"
                }
            }
        }
    }
}

```

but this does not

```auto
{
    "query": {
        "filter": {
            "term": {
                "field1": "value1"
            }
        }
    }
}

```

I only want to filter on a single field, so why do I need to wrap "filter" inside "bool", which is meant to allow querying/filtering on multiple criteria?

Note: the following works but ES computes a score for each hit and I want to avoid the score computation hence the need to use "filter". I thought I could just wrap "term" inside "filter" and be done, but no, I have to again wrap "filter" inside "bool"

```auto
{
	"query": {
		"term": {
			"field1": "value1"
		}
	}
}

```

---

<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 28, 2022, 2:45am UTC](https://discuss.elastic.co/t/why-do-i-have-wrap-filter-inside-bool-when-im-only-filtering-for-a-single-field/308306/2 "2022-06-28T02:45:38Z")

</div>

> [@thomas708](#):
>
> I only want to filter on a single field, so why do I need to wrap "filter" inside "bool", which is meant to allow querying/filtering on multiple criteria?

Maybe because the filter is a [bool ocurrence](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:** [July 26, 2022, 2:46am UTC](https://discuss.elastic.co/t/why-do-i-have-wrap-filter-inside-bool-when-im-only-filtering-for-a-single-field/308306/3 "2022-07-26T02:46:21Z")

</div>

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