# Terms Aggregation Bucket Sort when doc\_count is equal

**URL:** https://discuss.elastic.co/t/terms-aggregation-bucket-sort-when-doc-count-is-equal/250509
**Category:** Elasticsearch
**Created:** [September 30, 2020, 1:13pm UTC](https://discuss.elastic.co/t/terms-aggregation-bucket-sort-when-doc-count-is-equal/250509 "2020-09-30T13:13:10Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![aan](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@aan](https://discuss.elastic.co/u/aan)
#### Post date: [September 30, 2020, 1:13pm UTC](https://discuss.elastic.co/t/terms-aggregation-bucket-sort-when-doc-count-is-equal/250509/1 "2020-09-30T13:13:10Z")

</div>

Hey. The documentation states that:

> By default, the terms aggregation will return the buckets for the top ten terms ordered by the doc\_count

I was just wondering what happens, when the doc\_count of several buckets is equal? I observed that buckets are then sorted by their \_key/\_term but I can't find any information confirming that behaviour.

Greatful, for any information on that. thanks 🙂  
Anton

---

<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: [October 28, 2020, 1:13pm UTC](https://discuss.elastic.co/t/terms-aggregation-bucket-sort-when-doc-count-is-equal/250509/2 "2020-10-28T13:13:12Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
