elasticsearch/elasticsearch — pull request #2213 by tzhou (2012-08-29 02:31:59+00:00)
Title: Permit full accuracy of results when limiting the size of a facet query

Fixed issue #1832

The current method used to implement a size limit on a facet query favors performance over accuracy. This is a result of the size limit being applied per shard before aggregation of the results.

I modified class org.elasticsearch.search.facet.terms.strings.TermsStringOrdinalsFacetCollector to check for a new configuration parameter and if enabled, override this behavior to return all of the facets in the sorted order on a per shard basis. The merge facet process will still apply the size limit to return the top N facets based on the counts.

The result of this is that the client receives full accuracy with a size limited facet query.