Elasticsearch grouping queries
Working with Elasticsearch and doing some analytics on data stored in that, sometimes I had to perform some queries that in SQL are very simple, like
SELECT fieldName, COUNT(*)
WHERE fieldName = X
GROUP BY fieldName
ORDER BY COUNT(*) DESC
With Elasticsearch you could obtain same results in different ways, but the more simple I found is:
I hope this could help someone.
Originally published at https://gabriele-decapoa.github.io.