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

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?

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