工作中遇到需要統(tǒng)計(jì)分組數(shù)量的查詢,記錄一下
GET /fy_roomel/_search
{
"size": 0,
"aggs": {
"groupNAME": {
"terms": {
"field": "district.keyword"
}
},
"count":{
"cardinality": {
"field": "district.keyword"
}
}
}
}
ps: 按區(qū)域分組, 統(tǒng)計(jì)有幾個(gè)區(qū)域文章來源:http://www.zghlxwxcb.cn/news/detail-728572.html
結(jié)果文章來源地址http://www.zghlxwxcb.cn/news/detail-728572.html
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 1,
"successful" : 1,
"skipped" : 0,
"failed" : 0
},
"hits" : {
"total" : {
"value" : 145,
"relation" : "eq"
},
"max_score" : null,
"hits" : [ ]
},
"aggregations" : {
"groupNAME" : {
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 0,
"buckets" : [
{
"key" : "包河區(qū)",
"doc_count" : 87
},
{
"key" : "瑤海區(qū)",
"doc_count" : 29
},
{
"key" : "津南區(qū)",
"doc_count" : 26
},
{
"key" : "蜀山區(qū)",
"doc_count" : 3
}
]
},
"count" : {
"value" : 4
}
}
}
到了這里,關(guān)于ES統(tǒng)計(jì)分組后的分組數(shù)量的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!