I have question. If I use histogram composite aggregation with setting size.
For example I have integer range. Each number bucket in aggregation represents 1 day (Using integer for date is not important).
If I use
size and say I want to get 10 buckets in result. Can I reliably use
after_key to select date of my agregation?
Because if I filter by specific date range I will also get buckets outside of filtered range because some documents will be there since histogram is created on interval field (Same is true for date histogram on
data_range field type).
I my idea is to use combination of
after_key to set real start date and
size to pick how many days of result I want.
What worries me is from documentation:
after_keyis usually the key to the last bucket returned in the response, but that isn’t guaranteed. Always use the returned
after_keyinstead of derriving it from the buckets.
Will I miss some buckets if is say:
after_key: 10 size: 5
after_key: 15 size: 5
Or maybe better question will be, what are the cases when last returned bucket does not match next after_key?
This would be usefull also for Kibana to display time correctly, but also some buckets may represent 30 years of range and only 1 month is usually queried. So if I can paginate properly I can save a lot.