How to get "top N + remainder"?

I'd like to have a pie chart with top 5 items but it would be lot more useful if I could also see all the rest of the data as 1 big "the rest" slice.

Anyone knows if this is possible?

do you use kibana, pip chart set descending ,if you use elasticsearch agg,you can set "size" paramter

Yes, that gets me the top N but how do you the remainder? (i.e. top 3 count and the count for rest of the terms). It's useful when you want to see how big proportion of the total volume the top N is.

kibana don't contain this function but es support it,i think you can submit a issue to discuss

Does anyone know how to do this just using ES REST API?

sorry i don't know,somebody re-develop kibana ,i suggest maybe you can review kibana code:grinning: