# How to retrieve the number of matched terms?

**URL:** https://discuss.elastic.co/t/how-to-retrieve-the-number-of-matched-terms/302430
**Category:** Elasticsearch
**Created:** [April 14, 2022, 12:33pm UTC](https://discuss.elastic.co/t/how-to-retrieve-the-number-of-matched-terms/302430 "2022-04-14T12:33:57Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Filip4D](https://avatars.discourse-cdn.com/v4/letter/f/977dab/32.png) [@Filip4D](https://discuss.elastic.co/u/Filip4D)
#### Post date: [April 14, 2022, 12:33pm UTC](https://discuss.elastic.co/t/how-to-retrieve-the-number-of-matched-terms/302430/1 "2022-04-14T12:33:57Z")

</div>

Hey everyone, is there a way to count the number of matching words in the results. I.e. if I have the following query, I'd like to know for the results set, how many of the words: african, american and male were matched (1, 2 or all 3).

I would like to sort the results first by number of matched words, then by account type and then after that by the relevance score. Is something like this possible? I know that Elasticsearch allows for a minimum\_should\_match parameter that checks against the number of matched terms, so this must be calculated somewhere. I'm just wondering if its possible to access this value?

Thank you!

```auto
GET /talent_portfolios/_search
{
  "query": {
      "match": {
        "title": "african american male"
      }
  }
}

```

---

<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: [May 12, 2022, 12:34pm UTC](https://discuss.elastic.co/t/how-to-retrieve-the-number-of-matched-terms/302430/2 "2022-05-12T12:34:07Z")

</div>

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