Details
-
Improvement
-
Status: Open
-
Minor
-
Resolution: Unresolved
-
9.0
-
None
-
None
Description
FacetFieldProcessorByArray (DV and UIF) each accumulate term facet counts into an array that directly corresponds to term ords (and is thus already sorted in index order). When facets are returned sorted in index-order (asc or desc), sorting to find return values can be shortcircuited once enough facet values have been found to return.
The performance gains are greatest for high-recall domain faceting over high-cardinality fields. Currently, iteration always goes from 0 to nTerms, so the case most negatively affected is "sort=index desc" – every term ord is currently visited (the case for "asc" as well), and is passed through the topTerms PriorityQueue essentially as if it were a FIFO queue (accordingly, for high-recall, high-cardinality cases, "index desc" performs far less well than "index asc").
By shortcircuiting "index asc" once enough terms have been collected, and by reversing the iteration direction for "index desc" and likewise shortcircuiting, a clear performance gain can be straightforwardly achieved.