Can elasticsearch do GROUP BY and ORDER BY count?

(jc) #1

Let's say I have dictionary application where people come and look up word definitions.

Im trying to visualize top N most popular words during some timeframe.

In SQL I would do it possibly like this:

SELECT word, count(*) as cnt FROM lookups GROUP BY word ORDER BY cnt DESC;

So I plan on dumping data into ES in this format for example:


Is aggregate query like that possible with ES?

(Magnus Bäck) #2

You'll want to do a terms aggregation.

(jc) #3


(jc) #4

Would I be able to set up those terms aggregations in kibana using some off the shelf chart?

(Magnus Bäck) #5

Yes. On the x axis settings (assuming a line chart; other kinds of visualizations works similarly), split the buckets, choose terms aggregation and the field you want to group by. You may find helpful.

(jc) #6

Fantastic. I was able to launch everything in docker in minutes and get nice visual.
Thank u!

(system) #7

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.