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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
