Count distinct on elastic search

后端 未结 4 1320
面向向阳花
面向向阳花 2020-12-11 07:07

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

Select distinct inv_number , count(1) from invoices;

But

4条回答
  •  醉酒成梦
    2020-12-11 07:19

    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.

提交回复
热议问题