Graph other than elastic search

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

Select distinct inv_number , count(1) from invoices; 

But it returns the total score of a specific account number.

+1
elasticsearch elasticsearch-plugin
source share
4 answers

Since the OP uses the sql4es jdbc driver, it requests a sql query for its use case:

 SELECT COUNT(DISTINCT inv_number) from invoices; 

it returns the number of different values ​​of the specified column

+2
source share
  { "size": 0, "aggs": { "total_invoices": { "terms": { "field": "inv_number" }, "aggs": { "unique_invoiceid": { "cardinality": { "field": "inv_number" } } } } } 

This will give you the account number as key and the distict value in unique_invoiceid

0
source share

Elasticsearch does not support deterministic DISTINCT counts ( source ). It only supports approximate individual counters, such as "number of items" . One of the methods for determining determinations of differences is to aggregate them using β€œterms” and to calculate the segments of the result.

0
source share

This should work to calculate exact values:

 curl -X POST "localhost:9200/invoices/_search?size=0&pretty" -H 'Content-Type: application/json' -d '{ "aggs" : { "types_count" : { "value_count" : { "field" : "inv_number" } }, "group_by_status": { "terms": { "field": "inv_number" } } } 

} "

0
source share

All Articles