# How to get match count in string field for one document?

**URL:** <https://discuss.elastic.co/t/how-to-get-match-count-in-string-field-for-one-document/364501>\
**Category:** Elasticsearch\
**Created:** [August 6, 2024, 9:47pm UTC](https://discuss.elastic.co/t/how-to-get-match-count-in-string-field-for-one-document/364501 "2024-08-06T21:47:44Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![karaagacylmaz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/karaagacylmaz/32/136589_2.png) [@karaagacylmaz](https://discuss.elastic.co/u/karaagacylmaz)\
**Post date:** [August 6, 2024, 9:47pm UTC](https://discuss.elastic.co/t/how-to-get-match-count-in-string-field-for-one-document/364501/1 "2024-08-06T21:47:44Z")

</div>

Here is my ex document:

```auto
        { "categoryId" : 8,
          "productId" : 12,
          "starLevel" : 4.2,
          "reviewList" : [
            "foo",
            "bar",
            "foo bar",
            "foo bar foo" ]
          },
         { "categoryId" : 8,
          "productId" : 11,
          "starLevel" : 4.6,
          "reviewList" : [
            "foo",
            "bar",
            "bar bar",
            "bar bar foo" ]
          },

```

And search code:

```auto
client.search({
            index: indexName,
            size: 200,
            body: {
                query: {
                    match: {
                        "reviewList": "*foo*"
                    }
                },
            }
        });

```

I can found right result with above query but i want to expand my query that include for all document like how many match on "reviewList" field.

**Like this: For ProductId:12 "foo" matched 4 times, for ProductId: 11 "foo" matched 2 times.**

How can i do?

In other words, I want to get highlighted field count as kibana doing.  
Thanks.
