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?
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.
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 .
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.