# How to get the Match Type in Elasticsearhc response?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080>\
**Category:** Elasticsearch\
**Created:** [May 16, 2018, 9:32am UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080 "2018-05-16T09:32:10Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![san88922](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@san88922](https://discuss.elastic.co/u/san88922)\
**Post date:** [May 16, 2018, 9:32am UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/1 "2018-05-16T09:32:10Z")

</div>

Hi Team,

In Elasticsearch we have types of matches like "Fuzzy", "Exact" etc.....  
is there any way that will get to know which type of match has happened for request query, in the elasticsearch response?

Thanks in advance

---

<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:** [May 16, 2018, 9:44am UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/2 "2018-05-16T09:44:39Z")

</div>

You can named your queries. Like this: [https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab#file-search\_kibana\_console-txt-L362-L457](https://gist.github.com/dadoonet/5179ee72ecbf08f12f53d4bda1b76bab#file-search_kibana_console-txt-L362-L457)

```auto
GET user/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match_phrase": {
            "name": {
              "query" : "david pilato",
              "_name": "phrase on name",
              "boost": 8.0
            }
          }
        },
        {
          "match": {
            "name": {
              "query": "david pilato",
              "operator": "and", 
              "_name": "all terms on name",
              "boost": 2.0
            }
          }
        },
        {
          "match": {
            "name": {
              "query": "david pilato",
              "operator": "or", 
              "_name": "at least one term on name",
              "boost": 1.8
            }
          }
        },
        {
          "match": {
            "name": {
              "query": "david pilato",
              "fuzziness": 2,
              "_name": "fuzzy on name",
              "boost": 1.0
            }
          }
        },
        {
          "match_phrase": {
            "comments": {
              "query" : "david pilato",
              "_name": "phrase on comments",
              "boost": 0.9
            }
          }
        },
        {
          "match": {
            "comments": {
              "query": "david pilato",
              "operator": "and", 
              "_name": "all terms on comments",
              "boost": 0.8
            }
          }
        },
        {
          "match": {
            "comments": {
              "query": "david pilato",
              "operator": "or", 
              "_name": "at least one term on comments",
              "boost": 0.7
            }
          }
        },
        {
          "match": {
            "comments.synonyms": {
              "query": "david pilato",
              "_name": "synonyms on comments",
              "boost": 0.6
            }
          }
        },
        {
          "match": {
            "comments": {
              "query": "david pilato",
              "fuzziness": 2,
              "_name": "fuzzy on comments",
              "boost": 0.2
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![san88922](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@san88922](https://discuss.elastic.co/u/san88922)\
**Post date:** [May 16, 2018, 5:10pm UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/3 "2018-05-16T17:10:31Z")

</div>

Could you please explain it briefly? requirement is when i fire a request to elasticsearch, if a word is matched, i wanted the match type in elasticsearch response...

---

<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:** [May 17, 2018, 12:02am UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/4 "2018-05-17T00:02:07Z")

</div>

Did you try the example I linked to?

---

<div class="post-metadata">

**Author:** ![san88922](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@san88922](https://discuss.elastic.co/u/san88922)\
**Post date:** [May 17, 2018, 3:55am UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/5 "2018-05-17T03:55:59Z")

</div>

yes i tried.. But the scenario you have explained above, hints about which incoming request is matched not about the which match has happened with document in the elasticsearch.

---

<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:** [May 17, 2018, 9:01am UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/6 "2018-05-17T09:01:09Z")

</div>

Could you provide a full recreation script as described in [About the Elasticsearch category](https://discuss.elastic.co/t/about-the-elasticsearch-category/21). It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

---

<div class="post-metadata">

**Author:** ![san88922](https://avatars.discourse-cdn.com/v4/letter/s/ea666f/32.png) [@san88922](https://discuss.elastic.co/u/san88922)\
**Post date:** [May 21, 2018, 5:20pm UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/7 "2018-05-21T17:20:42Z")

</div>

@dadoonet Thanks for the explaination, i was able to understand the query, it suits my requirement.

---

<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:** [June 18, 2018, 5:20pm UTC](https://discuss.elastic.co/t/how-to-get-the-match-type-in-elasticsearhc-response/132080/8 "2018-06-18T17:20:44Z")

</div>

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