# Getting phrase count for each document separately

**URL:** <https://discuss.elastic.co/t/getting-phrase-count-for-each-document-separately/17081>\
**Category:** Elasticsearch\
**Created:** [April 18, 2014, 3:48pm UTC](https://discuss.elastic.co/t/getting-phrase-count-for-each-document-separately/17081 "2014-04-18T15:48:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Amit\_3](https://avatars.discourse-cdn.com/v4/letter/a/d78d45/32.png) [@Amit\_3](https://discuss.elastic.co/u/Amit_3)\
**Post date:** [April 18, 2014, 3:48pm UTC](https://discuss.elastic.co/t/getting-phrase-count-for-each-document-separately/17081/1 "2014-04-18T15:48:03Z")

</div>

I would like to get a phrase count for every document.  
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 very_ fast"  
}

I would like to query my documents for the word "_very_" and get back  
something like this:  
{  
"name" : "John",  
"Message" : "The lion is \*very \*fast",  
_"score" : 1_  
}

{  
"name" : "Ben",  
"Message" : "The lion is _very very_ fast",  
_"score" : 2_  
}

I failed to find out how to do this so far. I only found queries that give  
the sum of phrase count of all documents together (in my example 3).  
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](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/51e15537-cb1f-4e49-926e-6b2a6fce56b4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/51e15537-cb1f-4e49-926e-6b2a6fce56b4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 1:35am UTC](https://discuss.elastic.co/t/getting-phrase-count-for-each-document-separately/17081/2 "2017-07-06T01:35:01Z")

</div>


