I want to write an Elasticsearch query to group by document on an attribute (say attr1), get only the top 10 result of this group by sorted by another attibute (say attr2) and in this result of 10 documents I need to find the max of an attribute (say attr3).
In sql, I would have written the same like this -
select max(attr3) from
(select top 10 * from
(select sum(xyz) as attr2, count(abc) as attr3 from sometable group by attr1 )
order by attr2 desc);
Could someone help me an analogous query in elasticsearch for it?
I found that if I perform a nested aggregation followed by pipeline aggregation then I was able to mimic the above stated SQL query. Following is the query payload I built -
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.