# Querying indexed data

**URL:** <https://discuss.elastic.co/t/querying-indexed-data/9079>\
**Category:** Elasticsearch\
**Created:** [September 20, 2012, 7:29pm UTC](https://discuss.elastic.co/t/querying-indexed-data/9079 "2012-09-20T19:29:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ali\_ilyas](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@ali\_ilyas](https://discuss.elastic.co/u/ali_ilyas)\
**Post date:** [September 20, 2012, 7:29pm UTC](https://discuss.elastic.co/t/querying-indexed-data/9079/1 "2012-09-20T19:29:25Z")

</div>

Hi,  
I have indexed data on elastic search node. The structure of document is it  
has two fields namely , name and message. In message it contains text. Now  
I want to count the occurance of some particular phrase that occurs in  
messages.  
Like [http://localhost:9200/big/data/INDEXES](http://localhost:9200/big/data/INDEXES) OF DOCUMENTS  
The structure of document is  
{  
"name":"xyz",  
"message":"i like to eat king's burger. I go there quite often"  
}  
Now I have like 40thousand records. I want to calculate how many times  
king's burger have been mentioned in the messages of all documents.  
I am not able to make query for this, I now its trivial stuff but I am  
quite new in elastic search. Your help is highly appreciated.

--

---

<div class="post-metadata">

**Author:** ![Sushant\_Shankar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sushant_shankar/32/2652_2.png) [@Sushant\_Shankar](https://discuss.elastic.co/u/Sushant_Shankar)\
**Post date:** [September 20, 2012, 7:47pm UTC](https://discuss.elastic.co/t/querying-indexed-data/9079/2 "2012-09-20T19:47:49Z")

</div>

Hi Ali,

If your index name is bigData, and the structure of the document is as you  
described, the count query would look something like this:

curl -XGET '[http://localhost:9200/bigData/\_search?](http://localhost:9200/bigData/_search?)' -d '  
{  
"query": {  
"query\_string": {  
"fields": ["message"],  
"query": ""king's burger""  
}  
}  
}'

You should see the count of this under response's hits then total

For reference, check  
out [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/request-body.html)

Try the Count  
API: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/count.html)

On Thursday, September 20, 2012 12:29:25 PM UTC-7, ali ilyas wrote:

> Hi,  
> I have indexed data on Elasticsearch node. The structure of document is  
> it has two fields namely , name and message. In message it contains text.  
> Now I want to count the occurance of some particular phrase that occurs in  
> messages.  
> Like [http://localhost:9200/big/data/INDEXES](http://localhost:9200/big/data/INDEXES) OF DOCUMENTS  
> The structure of document is  
> {  
> "name":"xyz",  
> "message":"i like to eat king's burger. I go there quite often"  
> }  
> Now I have like 40thousand records. I want to calculate how many times  
> king's burger have been mentioned in the messages of all documents.  
> I am not able to make query for this, I now its trivial stuff but I am  
> quite new in Elasticsearch. Your help is highly appreciated.

--

---

<div class="post-metadata">

**Author:** ![ali\_ilyas](https://avatars.discourse-cdn.com/v4/letter/a/439d5e/32.png) [@ali\_ilyas](https://discuss.elastic.co/u/ali_ilyas)\
**Post date:** [September 21, 2012, 1:15pm UTC](https://discuss.elastic.co/t/querying-indexed-data/9079/3 "2012-09-21T13:15:36Z")

</div>

Thanks Sushant , it worked fine.

On Thursday, September 20, 2012 9:47:49 PM UTC+2, Sushant Shankar wrote:

> Hi Ali,
> 
> If your index name is bigData, and the structure of the document is as you  
> described, the count query would look something like this:
> 
> curl -XGET '[http://localhost:9200/bigData/\_search?](http://localhost:9200/bigData/_search?)' -d '  
> {  
> "query": {  
> "query\_string": {  
> "fields": ["message"],  
> "query": ""king's burger""  
> }  
> }  
> }'
> 
> You should see the count of this under response's hits then total
> 
> For reference, check out  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/search/request-body.html)
> 
> Try the Count API:  
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/api/count.html)
> 
> On Thursday, September 20, 2012 12:29:25 PM UTC-7, ali ilyas wrote:
> 
> > Hi,  
> > I have indexed data on Elasticsearch node. The structure of document is  
> > it has two fields namely , name and message. In message it contains text.  
> > Now I want to count the occurance of some particular phrase that occurs in  
> > messages.  
> > Like [http://localhost:9200/big/data/INDEXES](http://localhost:9200/big/data/INDEXES) OF DOCUMENTS  
> > The structure of document is  
> > {  
> > "name":"xyz",  
> > "message":"i like to eat king's burger. I go there quite often"  
> > }  
> > Now I have like 40thousand records. I want to calculate how many times  
> > king's burger have been mentioned in the messages of all documents.  
> > I am not able to make query for this, I now its trivial stuff but I am  
> > quite new in Elasticsearch. Your help is highly appreciated.

--

---

<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, 3:11am UTC](https://discuss.elastic.co/t/querying-indexed-data/9079/4 "2017-07-06T03:11:59Z")

</div>


