Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
-
None
-
New
Description
Today collectors cannot know about the Weight, and thus they cannot leverage Weight#count. IndexSearcher#count works around it by extending TotalHitCountCollector in order to shortcut counting the number of hits on a segment via Weight#count whenever possible.
It works, but I would prefer this shortcut to work for all users of TotalHitCountCollector. For instance the faceting module creates a MultiCollector over a TotalHitCountCollector and a FacetCollector, and today it doesn't benefit from quick counts, which would enable it to only collect matches into a FacetCollector.
I'm considering adding a new Collector#setWeight API to allow collectors to leverage Weight#count. I gave TotalHitCountCollector as an example above, but this could have applications for our top-docs collectors too, which could skip counting hits at all if the weight can provide them with the hit count up-front.
Attachments
Issue Links
- links to