Please see the gist for full example:
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.