Getting phrase count for each document separately


(Amit-3) #1

I would like to get a phrase count for each document separately.
I do not wish to run a query for every document, i would rather run one
single query.

For example if i have the following documents:
{
"name" : "John",
"message" : "The lion is *very *fast"
}

{
"name" : "Ben",
"message" : "The lion is *very *fast and the bardelas is very fast
"

}

I would like to query my documents for the phrase "very fast" and get
back something like this:
{
"name" : "John",
"message" : "The lion is *very *fast",
"count" : 1

}

{
"name" : "Ben",
"message" : "The lion is *very *fast and the bardelas is very
fast
",
"count" : 2
}

I failed to find out how to do this so far. I only found queries that give
the total number of documents that contain the phrase (in my example 2
documents).
How can I do this using elastic search query?
Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/3f1aefe9-97fa-44ba-a4b1-644536bd2a5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(system) #2