I'm a bit new to ES and I'm not sure how to do the following:
I run a search with a query which will only contain a few 'should' parameters.
Then also a few aggregations, e.g. a percentile, term bucketing, etc.
But for the aggregations, I only want it, e.g., aggregated over the first 1000 documents (which I hope is then scored and ordered by the score).
The idea is that I want the aggs for specific terms, but if not enough are found, then fill it up - but limited to a specific max number to aggregate on. From the docs it seems that size
is the number of documents it returns, not the size that will be used for the aggs (I do not need hits, only aggs returned).
So how do I go about this? Is there a nested/subsequent query? Must I pipeline
something, e.g. get the search for 1k docs, then agg that?
It would be ideal if the documents could first be sorted by the timestamp it was indexed - so that the documents that is used to 'fill up' are the latest - but AFAIK that is not possible?
Fill it up?
'fill it up' means I have 100 docs for one specified 'should' field specified. Then I still need the other 900 docs for the required the 1k result size to aggregate over (so to fill it up to the number required). So instead of using a filter I saw the 'combined queries' in the docs and I think using a 'should' parameter would suffice.