# Can't seem to grasp query filters

**URL:** <https://discuss.elastic.co/t/cant-seem-to-grasp-query-filters/115811>\
**Category:** Elasticsearch\
**Created:** [January 17, 2018, 2:08am UTC](https://discuss.elastic.co/t/cant-seem-to-grasp-query-filters/115811 "2018-01-17T02:08:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![arisbanach](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@arisbanach](https://discuss.elastic.co/u/arisbanach)\
**Post date:** [January 17, 2018, 2:08am UTC](https://discuss.elastic.co/t/cant-seem-to-grasp-query-filters/115811/1 "2018-01-17T02:08:19Z")

</div>

I'm trying to understand exactly how Elasticsearch queries work, but I'm having a tough time with the concept of filters and exact values.

- using `filter` within a `query` is boolean in the sense that it doesn't contain a score and will completely eliminate any results that don't fit the filter conditions, right?

- `must` within a `bool` is different from `filter` because it will still return results which don't match the conditions, and will include a score? doesn't that make it not a boolean?

- what is the purpose of wrapping `filter` in `bool` if the values are always boolean anyway?

- do aggregations include results that are filtered?

---

<div class="post-metadata">

**Author:** ![val](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/val/32/138203_2.png) [@val](https://discuss.elastic.co/u/val)\
**Post date:** [January 17, 2018, 3:36am UTC](https://discuss.elastic.co/t/cant-seem-to-grasp-query-filters/115811/2 "2018-01-17T03:36:36Z")

</div>

In the `bool` world, the story goes like this:

- `must` clauses imply scoring
- `filter` clauses are exactly like `must` just they don't imply any scoring at all

In `filter`, you will usually shove exact queries (so called [term-level queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/term-level-queries.html)), i.e. `term` queries or `match` queries on keyword fields, `range` queries, etc  
In `must`, you will usually shove [full text queries](https://www.elastic.co/guide/en/elasticsearch/reference/current/full-text-queries.html), i.e. `match` and `match_phrase` queries, `query_string` queries, etc

Nothing prevents you to have full-text queries in `filter` and term-level queries in `must`, but that makes less sense.

---

<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:** [February 14, 2018, 3:36am UTC](https://discuss.elastic.co/t/cant-seem-to-grasp-query-filters/115811/3 "2018-02-14T03:36:41Z")

</div>

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