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

Adrien Grand commented on LUCENE-6639:
--------------------------------------

I think there are two natural places where we can call policy.onUse(): 
Query.createWeight and Weight.scorer. None of them is perfect: if we put it in 
Query.createWeight, we will over-count how many times the query has been used 
if the weight is created yet never used, or under-count if the weight is used 
several times. And in Weight.scorer we under-count if no scorer is pulled on 
the first leaf as you noticed. Out of these two options, Weight.scorer is my 
favourite because it can never over-count, which I think it better given that 
caching too much is probably more harmful than not caching enough?

We could try to do something more sophisticated but I'm not sure it would be 
worth the complexity?

> LRUQueryCache.CachingWrapperWeight not calling policy.onUse() if the first 
> scorer is skipped
> --------------------------------------------------------------------------------------------
>
>                 Key: LUCENE-6639
>                 URL: https://issues.apache.org/jira/browse/LUCENE-6639
>             Project: Lucene - Core
>          Issue Type: Bug
>    Affects Versions: 5.3
>            Reporter: Terry Smith
>            Priority: Minor
>         Attachments: LUCENE-6639.patch
>
>
> The method 
> {{org.apache.lucene.search.LRUQueryCache.CachingWrapperWeight.scorer(LeafReaderContext)}}
>  starts with
> {code}
> if (context.ord == 0) {
>     policy.onUse(getQuery());
> }
> {code}
> which can result in a missed call for queries that return a null scorer for 
> the first segment.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to