# Getting error when using variable\_width\_histogram aggregation 'Too many buckets'

**URL:** <https://discuss.elastic.co/t/getting-error-when-using-variable-width-histogram-aggregation-too-many-buckets/346695>\
**Category:** Elasticsearch\
**Created:** [November 8, 2023, 10:34am UTC](https://discuss.elastic.co/t/getting-error-when-using-variable-width-histogram-aggregation-too-many-buckets/346695 "2023-11-08T10:34:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chandra\_Shekhar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/chandra_shekhar/32/122758_2.png) [@Chandra\_Shekhar](https://discuss.elastic.co/u/Chandra_Shekhar)\
**Post date:** [November 8, 2023, 10:34am UTC](https://discuss.elastic.co/t/getting-error-when-using-variable-width-histogram-aggregation-too-many-buckets/346695/1 "2023-11-08T10:34:22Z")

</div>

We are trying to execute a query to get variable\_width\_histogram aggregation results but getting an error 'Trying to create too many buckets'. However bucket size in query is 10. When trying to get bucket size 8, I am able to get results correctly but with size 10, this error is coming.

```auto
{
  "query": {
    "bool": {
      "filter": [
        {
          "bool": {
            "must": [
              {
                "query_string": {
                  "fields": [
                    "field1",
                    "field2"
                  ],
                  "default_operator": "AND",
                  "query": "(product1)"
                }
              }
            ]
          }
        }
      ],
      "must": [],
      "must_not": []
    }
  },
  "size": 0,
  "aggs": {
    "minMaxPriceRangeData": {
      "filter": {
        "bool": {
          "must": []
        }
      },
      "aggs": {
        "piceRangeData": {
          "variable_width_histogram": {
            "field": "value",
            "buckets": 10
          }
        }
      }
    }
  }
}

```

Total result doc count are 7974263 on which this query is running. Is there any other way we can extract similar data without any error?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 6, 2023, 10:34am UTC](https://discuss.elastic.co/t/getting-error-when-using-variable-width-histogram-aggregation-too-many-buckets/346695/2 "2023-12-06T10:34:47Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
