This aggregation creates too many buckets (10001) and will throw an error in future versions. You should update the [search.max_buckets] cluster setting or use the [
composite] aggregation to paginate all buckets in multiple requests.
We are using 6.2.2 version. Let us know what steps we should be doing to get away from this issue.