[ 
https://issues.apache.org/jira/browse/LUCENE-10620?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17555001#comment-17555001
 ] 

Adrien Grand commented on LUCENE-10620:
---------------------------------------

I opened a draft PR that demonstrates the idea: 
https://github.com/apache/lucene/pull/964.

> Can we pass the Weight to Collector?
> ------------------------------------
>
>                 Key: LUCENE-10620
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10620
>             Project: Lucene - Core
>          Issue Type: Improvement
>            Reporter: Adrien Grand
>            Priority: Minor
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 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.



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to