How to use Executing Aggregations group by with one condition?


(Ngọc Phạm) #1

hi , im newbie in elasticsearch and i have one question. Please help me. Thanks you very much.

im trying use Executing Aggregations to count data in elasticsearch.
in this link : https://www.elastic.co/guide/en/elasticsearch/reference/current/_executing_aggregations.html

it can excute first query like SELECT state, COUNT(*) FROM bank GROUP BY state ORDER BY COUNT(*) DESC

now i want add more condition (employee) like this

SELECT state, COUNT(*) FROM bank WHERE employee='1' GROUP BY state ORDER BY COUNT(*) DESC

how to write aggreation?

Thanks for your help

p/s: i see one line is "sum_other_doc_count" in resut when i excute first query. What that mean?.
i have total 135739 doc, and i have
"doc_count_error_upper_bound" : 0,
"sum_other_doc_count" : 133936.
i dont know 133936 and 135739 have any relation .


(system) #2