ElasticSearch generates aggregation results based on all query hits, regardless of the from and size parameters. This is what we want in most cases, but I have a special case when I need to restrict aggregation to vertices N. The restriction filter is not suitable, because it does not extract the best N elements, but only the first X that matches the query (for the splinter) independently from their assessment.
Is there a way to build a query whose hit counter has an upper limit of N to be able to build aggregation limited to these results in upper N? And if so, how?
Auxiliary question: Limiting the evaluation of matching documents can be an alternative, although in my case I would require a fixed binding. Does min_score affect aggregation?
source share