使用弹性搜索的术语聚合中的准确文档计数

Accurate document counts in terms aggregations with elastic search

我需要术语聚合的确切计数,我看到了弹性搜索 is not always accurate。我想知道是否有另一种解决方案来克服这个限制。

可以在聚合查询中设置size为0:

{
  "aggs" : {
    "products" : {
        "terms" : {
            "field" : "product",
            "size" : 0
        }
    }
  }
}

但是根据文档:

It is possible to not limit the number of terms that are returned by setting size to 0. Don’t use this on high-cardinality fields as this will kill both your CPU since terms need to be return sorted, and your network.