# Generate the counts of the search terms in one request

**URL:** https://discuss.elastic.co/t/generate-the-counts-of-the-search-terms-in-one-request/32716
**Category:** Elasticsearch
**Created:** [October 21, 2015, 7:22pm UTC](https://discuss.elastic.co/t/generate-the-counts-of-the-search-terms-in-one-request/32716 "2015-10-21T19:22:15Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![lucyy](https://avatars.discourse-cdn.com/v4/letter/l/cc9497/32.png) [@lucyy](https://discuss.elastic.co/u/lucyy)
#### Post date: [October 21, 2015, 7:22pm UTC](https://discuss.elastic.co/t/generate-the-counts-of-the-search-terms-in-one-request/32716/1 "2015-10-21T19:22:15Z")

</div>

I 'm doing text search using some key words or phrases(such as flu, fever and sore throat). Then I want to know the number of hits of each key word (phrase). I know I could do individual query request of each search term then aggregate like the following.

GET /tweets/\_search?search\_type=count  
{  
"query": {  
"filtered": {"query": {"match": {"text": "flu"}}}  
},  
"aggs":{  
"flu": {"value\_count": {"field": "id"}}}  
}

GET /tweets/\_search?search\_type=count  
{  
"query": {  
"filtered": {"query": {"match\_phrase": {"text": "sore throat"}}}  
},  
"aggs":{  
"sore throat": {"value\_count": {"field": "id"}}}  
}

Is there a way that I could generate the counts of the search terms in one request and get the results like the following, because I have near one hundred search terms.

"aggregations": {  
"sore throat": {"value": 429041},  
"flu": {"value": 4000294},  
"fever": {"value": 213302},  
......  
}

Thank you !

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [October 21, 2015, 8:52pm UTC](https://discuss.elastic.co/t/generate-the-counts-of-the-search-terms-in-one-request/32716/2 "2015-10-21T20:52:47Z")

</div>

Doing multiple requests is the right approach. If you want to get everything in a single round-trip, you could use the [multi-search](https://www.elastic.co/guide/en/elasticsearch/reference/1.7/search-multi-search.html) endpoint.

---

<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 5, 2017, 11:43pm UTC](https://discuss.elastic.co/t/generate-the-counts-of-the-search-terms-in-one-request/32716/3 "2017-07-05T23:43:26Z")

</div>


