Sum_bucket cardinality 多层 aggregation

Elasticsearch版本为5.5
以下方法1可以得到user里面cardinality的value加总,但是方法2却会得到以下错误讯息,
buckets_path must reference either a number value or a single value numeric metric aggregation
请问是哪里出错?或是其他方法可以统计数据?

方法1:
{
"size": 0,
"aggs": {
"city": {
"terms": {
"field": "city"
},
"aggs": {
"user": {
"cardinality": {
"field": "user"
}
}
}
},
"count_user":{
"sum_bucket":{
"buckets_path":"city>user"
}
}
}
}

方法2:
{
"size": 0,
"aggs": {
"city": {
"terms": {
"field": "city"
},
"aggs": {
"user": {
"terms": {
"field": "user"
},
"aggs": {
"gender": {
"cardinality": {
"field": "gender"
}
}
}
}
}
},
"count_user":{
"sum_bucket":{
"buckets_path":"city>user>gender"
}
}
}
}

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