Самый быстрый способ подсчитать все результаты в Lucene (java)

What is the fastest way to count all results for a given Query in Lucene?

  1. TopDocs.totalHits
  2. implement and manage a Filter, using QueryFilter
  3. implement a custom 'counting' Collector. This simply increments a count in the collect(int doc) method and returns true for the acceptsDocOutOfOrder() method. All other methods are NOOPS.

Since 1. will do scoring on all docs, and 2. could have an upfront hit due to loading of the FieldCache, I assume the answer is 3. It just seems odd that Lucene doesn't provide such a collector out of the box?

9
задан npellow 7 February 2011 в 07:42
поделиться