select countryName, count( distinct(countryId) ) as findCount from city group by countryName having findCount > 1
请问如何用es的agg实现上面的SQL,如果能,请给个例子,谢谢
select countryName, count( distinct(countryId) ) as findCount from city group by countryName having findCount > 1
请问如何用es的agg实现上面的SQL,如果能,请给个例子,谢谢
4 个回复
martindu - 搜披露创始人
赞同来自:
参考https://www.elastic.co/guide/e ... .html
Todo - 程序猿
赞同来自:
szwx855 - Easy Simple
赞同来自:
"size": 0,
"aggs": {
"all": {
"terms": {
"field": "cfg_id",
"min_doc_count": 2
},
"aggs": {
"count(distinct)": {
"cardinality": {
"field": "name"
}
}
}
}
}
}
enjoyhot
赞同来自:
"query" : {
"constant_score" : {
"filter" : {
"range" : { "drt" : { "from" : "2015-06-01", "to" : "2015-06-01" }}
}
}
},
"size":0,
"aggs": {
"top_num": {
"terms": {
"field": "imei",
"order": { "distinct_apps": "desc"}
},
"aggs": {
"distinct_apps":{
"cardinality" : {
"field" : "app"
}
}
}
}
}
发现内存占用高(数据量近千万),不知道有没有经验介绍,谢谢。