Cardinality 实际上就是做count(distinct)但是cardinality有5%的错误率,但是性能在100ms左右
1、precision_threshold优化准确率和内存开销
GET /tvs/sales/_search
{
"size" : 0,
"aggs" : {
"distinct_brand" : {
"cardinality" : {
"field" : "brand",
"precision_threshold" : 100 //默认值是100
}
}
}
}