三人行必有我师

es聚合的问题

Elasticsearch | 作者 redhat | 发布于2018年12月21日 | 阅读数:2356

聚合是基于搜索的结果进行汇总,但在实际中,我发现搜索结果中不存在的数据,在聚合里却出现了
{
"size": 0,
"query": {
"bool": {
"filter": [
{
"term": {
"esType": "recognize"
}
}

]
}
},
"aggregations": {
"platformAggs": {
"terms": {
"field": "platform",
"size": 5,
"min_doc_count": 0

}

}
}
}
结果:
"aggregations": {

"platformAggs": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": "HTML",
"doc_count": 49155
}
,
{
"key": "ANDROID",
"doc_count": 90
}
,
{
"key": "IOS",
"doc_count": 25
}
,
{
"key": "",
"doc_count": 0
}
,
{
"key": "WXAPP",
"doc_count": 0
}
]
}

}
在查询条件下,并不存在key 为""
和 key 为WXAPP的
已邀请:

walter123 - IT

赞同来自: psc0606 redhat

min_doc_count 参数的问题;参考截图

psc0606

赞同来自:

楼上说得对,你通过min_doc_count=0强制返回了空桶

要回复问题请先登录注册