Aggregation on top N results


This comes from 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?

(Doug Turnbull) #2

Maybe you want the experimental sampler aggregation? I have an example
using US high school data that uses a sampler aggregation to answer
questions about students most similar to one under analysis. It uses a
sampler aggregation to learn the predominant characteristics of the N most
similar students.

(If you're interested I'll be demoing this the at ElasticOn)


(system) #3