我们对处理高基数索引很感兴趣。(众所周知这是弹性搜索的一个问题)
我们已经从你那里知道了
select count(distinct high_cardinality_field) from my_table您已经有了一些优化来计算它。有一天会不会写这样的东西:
select count_via_hyperloglog(high_cardinality_field) from my_table把count_via_hyperloglog作为UDF或者什么的,就像现在可以通过ES插件在ES中一样吗?
发布于 2014-03-24 10:31:35
在机箱中,这个特性作为一个额外的聚合函数出现在我们的待办事项清单上,它使用的是超级日志算法。我们计划执行从presto http://prestodb.io/docs/current/functions/aggregate.html派生的命名。然后,您的示例可能会如下所示:
select approx_distinct(high_cardinality_field) from my_table但是,每个表的一个特定字段可能的性能改进是根据高基数字段对表进行聚类,如https://crate.io/docs/current/sql/ddl.html#routing下面所述。
发布于 2014-03-24 07:13:56
使用HyperLogLog进行高基数计数计划为1.1.0,文档已经准备就绪:http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-aggregations-metrics-cardinality-aggregation.html
示例:
{
"aggs" : {
"author_count" : {
"cardinality" : {
"field" : "author"
}
}
}
}对于像UDF这样的东西,您可以使用脚本、.e.g。通过将过滤聚合与脚本过滤器结合起来
{
"aggs": {
"in_stock_products": {
"filter": {
"script": {
"script": "doc['price'].value > minPrice"
"params": {
"minPrice": 5
}
}
},
"aggs": {
"avg_price": {
"avg": {
"field": "price"
}
}
}
}
}
}https://stackoverflow.com/questions/22602163
复制相似问题