elasticsearch/elasticsearch — pull request #8035 by jpountz (2014-10-09 12:08:34+00:00)
Title: Aggregations: Memory-bound terms.

This pull request is only a first building block for #6697. It doesn't change
anything and is not ready for review yet.

Utility classes to compute the top terms sorted either by term or count in a
streaming fashion. In both cases, we rely on priority queues.

Sorting by term produces accurate results. Sorting by count (only desc is
supported, not asc) is based on the space-saving algorithm:
https://icmi.cs.ucsb.edu/research/tech_reports/reports/2005-23.pdf
and is not fully accurate.