Elasticsearch Aggregation question

(taewooKim) #1

Can i implement the following mysql query with elasticsearch?

select sum(column1)/sum(column2) v1, min(column3) v2, sum(column4) v3 
from mytable 
group by column5, column6

Thank you for writing an example!

(Zachary Tong) #2

Should be doable! I'm on the run so I can't work out a full example, but I would do:

  • Terms aggregation on column5
    • Terms aggregation on column6
      • min agg on column3
      • sum agg on column1, column2, column3
      • bucket_script which divides sum(column1) / sum(column2)