# Get all the facet aggregate results

**URL:** <https://discuss.elastic.co/t/get-all-the-facet-aggregate-results/12052>\
**Category:** Elasticsearch\
**Created:** [May 21, 2013, 11:01am UTC](https://discuss.elastic.co/t/get-all-the-facet-aggregate-results/12052 "2013-05-21T11:01:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyrilcherian](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@cyrilcherian](https://discuss.elastic.co/u/cyrilcherian)\
**Post date:** [May 21, 2013, 11:01am UTC](https://discuss.elastic.co/t/get-all-the-facet-aggregate-results/12052/1 "2013-05-21T11:01:41Z")

</div>

HI,

I am new to elastic search.  
I was doing some research on facet when I stumbled upon a problem where I need **al** l the aggregated data based on a search query.  
Currently the facet return only the first 10 aggregated data.

Example:  
_curl -XGET '[http://localhost:9200/twitter/tweet/\_search?pretty=true](http://localhost:9200/twitter/tweet/_search?pretty=true)' -d '  
{  
"query" : { "query\_string" : {"query" : "\*"} },  
"size":0,  
"facets" : {  
"tags" : { "terms" : {"field" : "country" } }  
}  
}'_

On running this I get  
{  
"took" : 9,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 29324,  
"max\_score" : 1.0,  
"hits" : []  
},  
"facets" : {  
"tags" : {  
"\_type" : "terms",  
"missing" : 0,  
"total" : 29324,  
"other" : 8570,  
"terms" : [ {  
"term" : "United States",  
"count" : 8081  
}, {  
"term" : "United Kingdom",  
"count" : 3768  
}, {  
"term" : "Spain",  
"count" : 1779  
},{  
"term" : "Uganda",  
"count" : 1639  
}, {  
"term" : "Brazil",  
"count" : 1541  
}, {  
"term" : "Canada",  
"count" : 1176  
}, {  
"term" : "Kenya",  
"count" : 834  
}, {  
"term" : "South Africa",  
"count" : 831  
}, {  
"term" : "Indonesia",  
"count" : 729  
}, {  
"term" : "Nigeria",  
"count" : 376  
} ]  
}  
}  
}

Now as you can see the facet aggregates are just 10, what should I do to get all the aggregates.

Thanks,  
Cyril

---

<div class="post-metadata">

**Author:** ![rahulnair](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rahulnair/32/2321_2.png) [@rahulnair](https://discuss.elastic.co/u/rahulnair)\
**Post date:** [May 23, 2013, 6:03am UTC](https://discuss.elastic.co/t/get-all-the-facet-aggregate-results/12052/2 "2013-05-23T06:03:55Z")

</div>

Hi,

Here is a solution for your question.

set the _size_ attribute inside the terms

curl -XPOST 'localhost:9200/posts/\_search?pretty=true' -d '  
{  
"query" : {  
"term" : { "content" : "obama" }  
},  
"facets" : {  
"tag" : {  
**"terms" : { "field" : "country",  
"size" : 1000,  
"all\_terms" : false }**  
}  
}  
}  
'  
here the _all\_terms_ if true: shows all the countries corresponding to the terms { even if the country count is zero }

Thanks,  
Rahul

---

<div class="post-metadata">

**Author:** ![cyrilcherian](https://avatars.discourse-cdn.com/v4/letter/c/e274bd/32.png) [@cyrilcherian](https://discuss.elastic.co/u/cyrilcherian)\
**Post date:** [July 16, 2013, 10:03am UTC](https://discuss.elastic.co/t/get-all-the-facet-aggregate-results/12052/3 "2013-07-16T10:03:00Z")

</div>

Thanks it worked for me!

---

<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, 2:26am UTC](https://discuss.elastic.co/t/get-all-the-facet-aggregate-results/12052/4 "2017-07-06T02:26:15Z")

</div>


