I've been working on a query that performs a composite aggregation with a large number of buckets. When I set the aggregation size to 50,000, all buckets fit in the response. However, after_key
is still present in the response.
Sending a second query with after
set to this value takes about the same amount of time as the first query (10 seconds or so) but returns no buckets and no after_key
, which wastes time and resources doing nothing.
So I have two questions about this:
- Is this intended behavior, or is this a bug? I would expect
after_key
to not be present if there are no more buckets, but the composite aggregation documentation doesn't specify the circumstances under whichafter_key
is present. - If the number of buckets is less than the aggregation
size
, is it guaranteed that there are no more buckets? If it is guaranteed then I can simply end pagination in that case.
I am using Elasticsearch 8.8.2.