This comes from http://stackoverflow.com/questions/25429903/limiting-aggreation-to-the-top-x-hits-in-elasticsearch which I have been trying to solve as well.
question: Is there any way to build a query whose hit count has an upper limit N in order to be able to build an aggregation limited to those top N results ? And if so how ?
Just to clarify, aggregation needs to be done on the top hits of the scope query, and not access the top hits of each bucket which (if i am right) is what the top_hits aggregation provides. i.e. is it possible to have a sub-aggregation of the top_hits aggregation? if so how?