You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "msfroh (via GitHub)" <gi...@apache.org> on 2025/11/24 22:14:25 UTC
[I] FilterWeight should delegate count() [lucene]
msfroh opened a new issue, #15450:
URL: https://github.com/apache/lucene/issues/15450
### Description
I was talking with a colleague today about a case where we're getting burned by eager computation of `Weight#count()` (which we can probably resolve by changing the order of our clauses to move the clause most likely to match nothing to the front of the BooleanQuery).
While talking about options to skip the attempted `Weight#count()` computation, I suggested throwing together a wrapping query that produces a `FilterWeight` that overrides the `count()` method to return -1. That's when I noticed that `FilterWeight` doesn't delegate the `count()` method and so it **does*** return -1.
I see from https://github.com/apache/lucene/pull/242 that not delegating `count` was a conscious decision (and is enforced in `TestFilterWeight`), maybe because it was safer to assume that any `FilterWeight` might mess with the wrapped `Weight`'s count. On the other hand, we **do** delegate `Weight#matches` by default. I think it's safe to say that if `FilterWeight#matches` behaves the same as the wrapped `Weight`, then `FilterWeight#count` must also behave the same as the wrapped `Weight`. (So, I feel like we should delegate both or delegate neither. I prefer delegating both.)
As a bonus, if we fix this, then we can remove [this whole block](https://github.com/apache/lucene/blob/ad24abfb0df055600f8a8d456ce3dfd7358542b2/lucene/core/src/test/org/apache/lucene/search/TestFilterWeight.java#L39-L60) from `TestFilterWeight`, since `Weight#bulkScorer()` is now `final`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] FilterWeight should delegate count() [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss closed issue #15450: FilterWeight should delegate count()
URL: https://github.com/apache/lucene/issues/15450
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] FilterWeight should delegate count() [lucene]
Posted by "blerer (via GitHub)" <gi...@apache.org>.
blerer commented on issue #15450:
URL: https://github.com/apache/lucene/issues/15450#issuecomment-3737710315
@dweiss You should be able to close that issue now. :-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] FilterWeight should delegate count() [lucene]
Posted by "prudhvigodithi (via GitHub)" <gi...@apache.org>.
prudhvigodithi commented on issue #15450:
URL: https://github.com/apache/lucene/issues/15450#issuecomment-3652686964
This makes sense to me, we should delegate `count()` in `FilterWeight` then the delegation happens to wrapped weight.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
Re: [I] FilterWeight should delegate count() [lucene]
Posted by "dweiss (via GitHub)" <gi...@apache.org>.
dweiss commented on issue #15450:
URL: https://github.com/apache/lucene/issues/15450#issuecomment-3737791061
Implemented in #15469
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org