# Filter Elasticsearch results based on the number of 'matched\_queries'

**URL:** <https://discuss.elastic.co/t/filter-elasticsearch-results-based-on-the-number-of-matched-queries/286741>\
**Category:** Elasticsearch\
**Created:** [October 14, 2021, 2:45pm UTC](https://discuss.elastic.co/t/filter-elasticsearch-results-based-on-the-number-of-matched-queries/286741 "2021-10-14T14:45:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NLSVTN](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nlsvtn/32/84889_2.png) [@NLSVTN](https://discuss.elastic.co/u/NLSVTN)\
**Post date:** [October 14, 2021, 2:45pm UTC](https://discuss.elastic.co/t/filter-elasticsearch-results-based-on-the-number-of-matched-queries/286741/1 "2021-10-14T14:45:24Z")

</div>

There is such a thing in `elasticsearch` as `named queries` :

> **[Demystifying Elasticsearch Queries, Part 3: Named Queries | Qbox HES](https://qbox.io/blog/elasticsearch-named-queries/)**
>
> In this article, we will take a look at one of the most useful type of query methods, which is the "naming" of queries or simply named queries with examples.

When we use it, we get `matched_queries` array together with each matched document in each `elasticsearch` hit. Now, I want to get only documents that matched `> n` queries. Is it possible to do and how?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 14, 2021, 2:59pm UTC](https://discuss.elastic.co/t/filter-elasticsearch-results-based-on-the-number-of-matched-queries/286741/2 "2021-10-14T14:59:33Z")

</div>

Why not using a bool query with a should array and minimum\_should\_match value to whatever you want? See [minimum\_should\_match parameter | Elasticsearch Guide [7.15] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html)

There's no need for named queries for that.

---

<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:** [November 11, 2021, 3:53pm UTC](https://discuss.elastic.co/t/filter-elasticsearch-results-based-on-the-number-of-matched-queries/286741/4 "2021-11-11T15:53:40Z")

</div>

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