标签:key ref mooc distinct ast tin path filter nali
# 每种型号车的颜色数 > 1的
SELECT model,COUNT(DISTINCT color) color_count FROM cars
GROUP BY model
HAVING color_count > 1
ORDER BY color_count desc
LIMIT 2;
GET cars/_search
{
"size": 0,
"aggs": {
"models": {
"terms": {
"field": "model.keyword"
},
"aggs": {
"color_count": {
"cardinality": {
"field": "color.keyword"
}
},
"color_count_filter": {
"bucket_selector": {
"buckets_path": {
"colorCount": "color_count"
},
"script": "params.colorCount>1"
}
},
"color_count_sort": {
"bucket_sort": {
"sort": {
"color_count": "desc"
},
"size": 2
}
}
}
}
}
}
https://cloud.tencent.com/developer/article/1367657
标签:key ref mooc distinct ast tin path filter nali
原文地址:https://www.cnblogs.com/iiiiiher/p/10190949.html