# Search count deprecated, how to get all buckets?

**URL:** <https://discuss.elastic.co/t/search-count-deprecated-how-to-get-all-buckets/46687>\
**Category:** Elasticsearch\
**Created:** [April 7, 2016, 1:26pm UTC](https://discuss.elastic.co/t/search-count-deprecated-how-to-get-all-buckets/46687 "2016-04-07T13:26:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![beckerdo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/beckerdo/32/8355_2.png) [@beckerdo](https://discuss.elastic.co/u/beckerdo)\
**Post date:** [April 7, 2016, 1:26pm UTC](https://discuss.elastic.co/t/search-count-deprecated-how-to-get-all-buckets/46687/1 "2016-04-07T13:26:34Z")

</div>

I have an aggregation that sums a field and buckets the field by another field.

I understand from [Elastic 2.3 release changes](https://www.elastic.co/guide/en/elasticsearch/reference/2.3/breaking_21_search_changes.html) that the search\_type=count is deprecated. I am running Elastic 2.2 and when I remove the search\_type=count and add a ""size":0" clause to the body, I get my aggregation counts as before.

However, with the size 0 clause I only see the first 10 buckets. How to do I get all the buckets of the aggregation and the counts?

Thanks, beckerdo

---

<div class="post-metadata">

**Author:** ![beckerdo](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/beckerdo/32/8355_2.png) [@beckerdo](https://discuss.elastic.co/u/beckerdo)\
**Post date:** [April 8, 2016, 3:25pm UTC](https://discuss.elastic.co/t/search-count-deprecated-how-to-get-all-buckets/46687/2 "2016-04-08T15:25:48Z")

</div>

I think I found the answer. If I put ""size": 0" in the aggregation term, then I get all the buckets. Putting ""size": 0" in the request body outer scope returns counts rather than full document.

So, in summary, you need two of these size clauses.

---

<div class="post-metadata">

**Author:** ![Chad\_Oliver](https://avatars.discourse-cdn.com/v4/letter/c/e47774/32.png) [@Chad\_Oliver](https://discuss.elastic.co/u/Chad_Oliver)\
**Post date:** [April 8, 2016, 4:47pm UTC](https://discuss.elastic.co/t/search-count-deprecated-how-to-get-all-buckets/46687/3 "2016-04-08T16:47:22Z")

</div>

What is the maximum number of buckets that can be returned when process an aggregation query that has the "size" set to 0?

---

<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:01pm UTC](https://discuss.elastic.co/t/search-count-deprecated-how-to-get-all-buckets/46687/4 "2017-07-05T23:01:05Z")

</div>


