# Count the number of times a phrase appears in document

**URL:** <https://discuss.elastic.co/t/count-the-number-of-times-a-phrase-appears-in-document/17060>\
**Category:** Elasticsearch\
**Created:** [April 17, 2014, 9:46am UTC](https://discuss.elastic.co/t/count-the-number-of-times-a-phrase-appears-in-document/17060 "2014-04-17T09:46:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Zweigenhaft](https://avatars.discourse-cdn.com/v4/letter/d/ce73a5/32.png) [@David\_Zweigenhaft](https://discuss.elastic.co/u/David_Zweigenhaft)\
**Post date:** [April 17, 2014, 9:46am UTC](https://discuss.elastic.co/t/count-the-number-of-times-a-phrase-appears-in-document/17060/1 "2014-04-17T09:46:35Z")

</div>

I am newer in Elastic Search.

I would like to count the number of times a particular phrase appears in a  
document. I am using the match\_phase query.

How can I can I do that for:

1. single document.

2. all the documents under root index/index&type - if it possible how to  
do that using a single query.

3. Actually, I would like to match several phrases and to get a different  
counter per each phrases (phrase1\_count, phrase2\_count, … phraseN\_count).  
Again, I need to do that for all the documents under a root  
index/index&type - if it possible how to do that using a single query.

Thanks in advanced.

--  
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/7e185b3a-aa39-4e44-8e29-e2447992d53e%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7e185b3a-aa39-4e44-8e29-e2447992d53e%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/count-the-number-of-times-a-phrase-appears-in-document/17060/2 "2017-07-06T01:35:18Z")

</div>


