# Is it possible to count number of matches when using should filter based on custom weight values?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-count-number-of-matches-when-using-should-filter-based-on-custom-weight-values/28231
**Category:** Elasticsearch
**Created:** [August 28, 2015, 8:06am UTC](https://discuss.elastic.co/t/is-it-possible-to-count-number-of-matches-when-using-should-filter-based-on-custom-weight-values/28231 "2015-08-28T08:06:06Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![luger888](https://avatars.discourse-cdn.com/v4/letter/l/ce73a5/32.png) [@luger888](https://discuss.elastic.co/u/luger888)
#### Post date: [August 28, 2015, 8:06am UTC](https://discuss.elastic.co/t/is-it-possible-to-count-number-of-matches-when-using-should-filter-based-on-custom-weight-values/28231/1 "2015-08-28T08:06:06Z")

</div>

For example, I have index `pizzas`. And I have Bool Filter

```
 "bool": {
      "should": {
          "toppings": [
            {
              "query": "Tomatoes"
            },
            {
              "query": "Mushrooms"
            }
          ]
        }
      }

```

Can ElasticSearch return match percentage for all pizzas in index, so all that have `mushrooms` XOR `tomatoes`, will return 50%, if both - 100%. And other toppings are irrelevant.

If yes, could we extend this functionality that way, so we could add for each topping weight value.  
For example I'm interested in Tomatoes(50) , in Mushrooms(75) and Chili(100).  
So in sum it will be 50 + 75 + 100 = 225  
So Margherita has Tomatoes and Muchrooms = 125.  
So this pizza match percentage should return near 56% ( 125/225).

I read ElasticSearch guide, read like hundred of times API docs, tried filters, queries, minimum\_should\_match, boost. I will really appreciate at least some direction where to search further.  
Sorry if I placed my question not in right place.  
Thanks.

---

<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 5, 2017, 11:53pm UTC](https://discuss.elastic.co/t/is-it-possible-to-count-number-of-matches-when-using-should-filter-based-on-custom-weight-values/28231/2 "2017-07-05T23:53:19Z")

</div>


