you could play around with a range aggregation, inside of that a terms aggregation on the category field with a size of 2 and inside of that a top_hits aggregation.
Another option is always to execute more than one search, but try the above first.
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.