Trying to create too many buckets Must be less than or equal – How to solve this Elasticsearch exception

Opster Team

August-23, Version: 6.8-7.15

Briefly, this error occurs when the number of buckets created during an aggregation query in Elasticsearch exceeds the limit set by the `search.max_buckets` cluster setting. This is to prevent memory issues. To resolve this, you can either increase the `search.max_buckets` limit or optimize your query to generate fewer buckets. Be cautious while increasing the limit as it may lead to OutOfMemoryError. Alternatively, you can use the `composite` aggregation to paginate all possible bucket combinations, which is more memory-friendly.

This guide will help you check for common problems that cause the log ” Trying to create too many buckets. Must be less than or equal ” to appear. To understand the issues related to this log, read the explanation below about the following Elasticsearch concepts: aggregations, search.

Log Context

Log “Trying to create too many buckets. Must be less than or equal” class name is CompositeAggregator.java. We extracted the following from Elasticsearch source code for those seeking an in-depth context :

 this.formats = Arrays.stream(sourceConfigs).map(CompositeValuesSourceConfig::format).collect(Collectors.toList());
 this.sources = new SingleDimensionValuesSource[sourceConfigs.length];
 // check that the provided size is not greater than the search.max_buckets setting
 int bucketLimit = context.multiBucketConsumer().getLimit();
 if (size > bucketLimit) {
 throw new MultiBucketConsumerService.TooManyBucketsException("Trying to create too many buckets. Must be less than or equal" +
 " to: [" + bucketLimit + "] but was [" + size + "]. This limit can be set by changing the [" + MAX_BUCKET_SETTING.getKey() +
 "] cluster level setting."; bucketLimit);
 }
 this.sourceConfigs = sourceConfigs;
 for (int i = 0; i < sourceConfigs.length; i++) {

 

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?