LuXugang commented on code in PR #12017:
URL: https://github.com/apache/lucene/pull/12017#discussion_r1049162892
##########
lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java:
##########
@@ -470,14 +470,19 @@ private int reqCount(LeafReaderContext context) throws
IOException {
private int optCount(LeafReaderContext context, Occur occur) throws
IOException {
final int numDocs = context.reader().numDocs();
int optCount = 0;
+ boolean unknownCount = false;
for (WeightedBooleanClause weightedClause : weightedClauses) {
if (weightedClause.clause.getOccur() != occur) {
continue;
}
int count = weightedClause.weight.count(context);
- if (count == -1 || count == numDocs) {
- // If any of the clauses has a number of matches that is unknown, the
number of matches of
- // the disjunction is unknown.
+ if (count == -1) {
+ // If one clause has a number of matches that is unknown, let's be
more aggressive to check
+ // whether remain clauses could match all docs.
+ unknownCount = true;
+ continue;
Review Comment:
addressed in
https://github.com/apache/lucene/pull/12017/commits/dc13ae7bddc3ca272af7c45dd998258984469904
##########
lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java:
##########
@@ -492,7 +497,10 @@ private int optCount(LeafReaderContext context, Occur
occur) throws IOException
return -1;
Review Comment:
Thanks @jpountz , you are right. addressed in
https://github.com/apache/lucene/pull/12017/commits/477b2a4e1f95f408562fc1745979bf9815ffaa75
##########
lucene/core/src/test/org/apache/lucene/search/TestBooleanQuery.java:
##########
@@ -1015,6 +1015,80 @@ public void testDisjunctionRandomClausesMatchesCount()
throws Exception {
}
}
+ public void testAggressiveMatchCount() throws IOException {
Review Comment:
addressed in
https://github.com/apache/lucene/pull/12017/commits/272dec54a59dedc666cf8311c09830c94b3c5369
--
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]