Uploaded image for project: 'Lucene - Core'
  1. Lucene - Core
  2. LUCENE-10620

Can we pass the Weight to Collector?

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • None
    • 9.3
    • 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

          Activity

            People

              Unassigned Unassigned
              jpountz Adrien Grand
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 2h 10m
                  2h 10m