Filter Elasticsearch results based on the number of 'matched_queries'

There is such a thing in elasticsearch as named queries :

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?

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

There's no need for named queries for that.

1 Like