# Avg\_bucket aggregation failed when buckets\_path include inner bucket with same name like sibling bucket

**URL:** <https://discuss.elastic.co/t/avg-bucket-aggregation-failed-when-buckets-path-include-inner-bucket-with-same-name-like-sibling-bucket/99296>\
**Category:** Elasticsearch\
**Created:** [September 4, 2017, 1:01pm UTC](https://discuss.elastic.co/t/avg-bucket-aggregation-failed-when-buckets-path-include-inner-bucket-with-same-name-like-sibling-bucket/99296 "2017-09-04T13:01:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![david206](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/david206/32/21794_2.png) [@david206](https://discuss.elastic.co/u/david206)\
**Post date:** [September 4, 2017, 1:01pm UTC](https://discuss.elastic.co/t/avg-bucket-aggregation-failed-when-buckets-path-include-inner-bucket-with-same-name-like-sibling-bucket/99296/1 "2017-09-04T13:01:52Z")

</div>

Please see the gist for full example:

> <https://gist.github.com/david206/7cf7af8eb27974e4cfe19763c858ed2a>

ES version: 5.2.2

avg\_bucket aggregation failed when buckets\_path include inner bucket with same name like sibling bucket:

The error:

```
{
  "error" : {
    "root_cause" : [],
    "type" : "reduce_search_phase_exception",
    "reason" : "[reduce] ",
    "phase" : "merge",
    "grouped" : true,
    "failed_shards" : [],
    "caused_by" : {
      "type" : "class_cast_exception",
      "reason" : "org.elasticsearch.search.aggregations.metrics.cardinality.InternalCardinality cannot be cast to org.elasticsearch.search.aggregations.InternalMultiBucketAggregation"
    }
  },
  "status" : 503
}

```

When the first bucket path is terms aggregation (and not date\_histogram) it works,  
And, when renaming the sibling bucket to unique name, it works as well.

---

<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:** [October 2, 2017, 1:02pm UTC](https://discuss.elastic.co/t/avg-bucket-aggregation-failed-when-buckets-path-include-inner-bucket-with-same-name-like-sibling-bucket/99296/2 "2017-10-02T13:02:38Z")

</div>

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