在弹性搜索上计数不同 [英] Count distinct on elastic search

查看:29
本文介绍了在弹性搜索上计数不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用sql4es驱动在弹性搜索类型上实现count distinct函数?

How to achieve count distinct function on elastic search type using sql4es driver?

Select distinct inv_number , count(1) from invoices;

但它返回特定发票编号的总数.

But it returns the total count of the particular invoice number.

推荐答案

Elasticsearch 不支持确定性 DISTINCT 计数 (来源).它仅支持近似的不同计数器,例如 基数".以确定性方式计算不同点的一种方法是使用术语"聚合它们并从结果中计算桶数.

Elasticsearch doesn't support deterministic DISTINCT counts (source). It supports only approximate distinct counters like "cardinality". One way to count distincts in a deterministic way is to aggregate them using "terms" and count buckets from result.

这篇关于在弹性搜索上计数不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆