0

Try to get a distinct count on an index containing field value more then once. i have differences between the SQL data and the elastic data, why is that?

Shahar
  • 1
  • 1
    Maybe you need to show some sample data, your mapping and the queries you're making... Help us help you ;-) – Val Jul 27 '20 at 09:33

2 Answers2

0

Cardinality Aggreagtion gives a count of distinct values. Values can be extracted either from specific fields in the document or generated by a script.

Refer this to know more about Cardinality Aggregation

You can even refer this thread to know more about how to count distinct on elasticsearch

ESCoder
  • 15,431
  • 2
  • 19
  • 42
  • but i did that and it is not giving me accurate results. in the post they saying that it is an approximate calculation – Shahar Jul 27 '20 at 12:39
  • @Shahar can you provide some sample data, your mappings and search query which u are using ? – ESCoder Jul 27 '20 at 12:47
  • i cant post all the sample data but i did an simple example of an index containing customer_id which has duplicates records the total for both sql and elastic are 11703. then in the kibana i have created a metric visualization with metric of unique count. in the distinct SQL statement on the same example im getting 6678 records and in the kibana im getting 6671 – Shahar Jul 27 '20 at 14:05
0

Accurate Distinct Count can be found from ES. You can refer the article on "Accurate Distinct Count and Values from Elasticsearch" for complete solution and comparison against Cardinality.