# How to get the total (count) ocurrences for each result?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-total-count-ocurrences-for-each-result/65133>\
**Category:** Elasticsearch\
**Created:** [November 6, 2016, 11:41am UTC](https://discuss.elastic.co/t/how-to-get-the-total-count-ocurrences-for-each-result/65133 "2016-11-06T11:41:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorrion5](https://avatars.discourse-cdn.com/v4/letter/g/a9a28c/32.png) [@gorrion5](https://discuss.elastic.co/u/gorrion5)\
**Post date:** [November 6, 2016, 11:41am UTC](https://discuss.elastic.co/t/how-to-get-the-total-count-ocurrences-for-each-result/65133/1 "2016-11-06T11:41:10Z")

</div>

I'm storing websites with the fields title, content(the website text), url and so on. I have to show in my search results the title and the number of ocurrences of a phrase(inside the content field) for that website( I mean, for each website, i think that i need to use aggs), grouped by title. I'm using ES 2.4.0.

My query would be something like this but this doesn't perform the search result that i want:

```
{
  "fields": ["title"],
  "query": {
    "match": {
      "content": {
        "query": "Android Studio",
        "type": "phrase"
      }
    }
  },
  "aggs": {
    .
    .
    .
  }
}

```

The result that i expect would be something like this:

```
Search term: Android Studio

Results for Android Studio

1 ) title -> Android Studio 2.2 released
     Times "Android Studio" were found: 6
2 ) title -> Android Studio vs Eclipse vs IntelliJ IDEA
     Times "Android Studio" were found: 2

```

Is it possible in a single query?

---

<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:** [December 4, 2016, 11:41am UTC](https://discuss.elastic.co/t/how-to-get-the-total-count-ocurrences-for-each-result/65133/2 "2016-12-04T11:41:23Z")

</div>

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