# Identifying what terms were matched in a match query

**URL:** <https://discuss.elastic.co/t/identifying-what-terms-were-matched-in-a-match-query/244202>\
**Category:** Elasticsearch\
**Created:** [August 7, 2020, 4:32pm UTC](https://discuss.elastic.co/t/identifying-what-terms-were-matched-in-a-match-query/244202 "2020-08-07T16:32:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daymon\_Schroeder](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daymon_schroeder/32/73524_2.png) [@Daymon\_Schroeder](https://discuss.elastic.co/u/Daymon_Schroeder)\
**Post date:** [August 7, 2020, 4:32pm UTC](https://discuss.elastic.co/t/identifying-what-terms-were-matched-in-a-match-query/244202/1 "2020-08-07T16:32:23Z")

</div>

Consider the following example query where we match a percentage of terms

```auto
    GET /_search
    {
      "query": {
        "bool": {
          "should": [
            {
              "match" : {
                "body": {
                  "query": "hello world textthatwontbefoundhere",
                  "search_analyzer": "custom_analyzer",
                  "minimum_should_match": "50%" 
                }
              }
            }
          ]
        }
      }
    }

```

Is there a way to identify what terms inside of the query were matched against so that we can inform the user in our UI what terms we are ignoring or are actually using from their input? (e.g. "showing results for 'hello world' instead of 'hello world textthatwontbefoundhere'") without running a full explain on the search?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [August 12, 2020, 9:58am UTC](https://discuss.elastic.co/t/identifying-what-terms-were-matched-in-a-match-query/244202/2 "2020-08-12T09:58:13Z")

</div>

the solution you are searching for would mean that the `showing results for` would potentially change for every hit.

Maybe you can use something like [highlighting](https://www.elastic.co/guide/en/elasticsearch/reference/7.8/highlighting.html) to give the user some more context about a search hit and thus let him/her decide easier.

---

<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:** [September 9, 2020, 9:58am UTC](https://discuss.elastic.co/t/identifying-what-terms-were-matched-in-a-match-query/244202/3 "2020-09-09T09:58:16Z")

</div>

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