# Return 'others' aggregation in ES result

**URL:** <https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637>\
**Category:** Elasticsearch\
**Created:** [April 18, 2016, 9:57am UTC](https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637 "2016-04-18T09:57:17Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![satya\_fury](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@satya\_fury](https://discuss.elastic.co/u/satya_fury)\
**Post date:** [April 18, 2016, 9:57am UTC](https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637/1 "2016-04-18T09:57:17Z")

</div>

Hi,  
does elasticsearch provide any option to return back others as aggregation i.e. when we say request for sum of salary for top 5 departments, can we get the sum of the remaining salary for other departments with the key as others?

---

<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:** [April 18, 2016, 1:30pm UTC](https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637/2 "2016-04-18T13:30:28Z")

</div>

This is not supported. Note however that you could work around it on client side by running a sum aggregation to get the total salary for all departments and then substract the salaries that you get from the top 5 departments.

---

<div class="post-metadata">

**Author:** ![satya\_fury](https://avatars.discourse-cdn.com/v4/letter/s/c37758/32.png) [@satya\_fury](https://discuss.elastic.co/u/satya_fury)\
**Post date:** [April 19, 2016, 9:37am UTC](https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637/3 "2016-04-19T09:37:52Z")

</div>

Hi, Thanks for the reply.  
The solution you provided will work great if the number of docs are less. But I am using data which runs into millions of rows, so it creates network congestion if I want to manipulate data at the front end .

---

<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:** [April 19, 2016, 3:29pm UTC](https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637/4 "2016-04-19T15:29:24Z")

</div>

I was not suggesting to retrieve all buckets, but to add another sum aggregation at the same level as your terms aggregation to get the sum of salaries across all departments.

---

<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, 10:58pm UTC](https://discuss.elastic.co/t/return-others-aggregation-in-es-result/47637/5 "2017-07-05T22:58:00Z")

</div>


