有个人长的像洋葱,走着走着就哭了…….

Elasticsearch 聚合不准确

Elasticsearch | 作者 chaochao6411 | 发布于2019年09月04日 | 阅读数:2232

Elasticsearch 聚合不准确

"aggregations": {
"count": {
"terms": {
"field": "type"
}
}
}
有很多种类type没有查出来
已邀请:

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

感谢邀请。
 
1.聚合本来就是不精确的。
看一下官方解读:As described above, the document counts (and the results of any sub aggregations) in the terms aggregation are not always accurate. 
https://www.elastic.co/guide/e ... .html
 
2.如何更精确的实践方法:
方案1:设置主分片为1。注意7.x版本已经默认为1。 
适用场景:数据量小的场景。 
 
方案2:设置shard_size为比较大的值,官方推荐:size*1.5+10 
适用:数据量大的场景。 
 
方案3:早期版本中,我曾经将size设置为2的32次方减去1也就是分片支持的最大值,来解决精度问题。
 
原因:1.x版本,size等于0代表全部,高版本取消0值,所以设置了最大值。 
适用场景:不推荐使用了。

要回复问题请先登录注册