jpountz commented on code in PR #950:
URL: https://github.com/apache/lucene/pull/950#discussion_r895526857


##########
lucene/core/src/java/org/apache/lucene/search/BooleanWeight.java:
##########
@@ -344,6 +344,45 @@ public BulkScorer bulkScorer(LeafReaderContext context) 
throws IOException {
     }
   }
 
+  @Override
+  public int count(LeafReaderContext context) throws IOException {
+    // Implement counting for pure conjunctions in the case when one clause 
doesn't match any docs,
+    // or all clauses but one match all docs.
+    if (weightedClauses.isEmpty()) {
+      return 0;
+    }
+    for (WeightedBooleanClause weightedClause : weightedClauses) {
+      switch (weightedClause.clause.getOccur()) {
+        case FILTER:
+        case MUST:
+          break;
+        case MUST_NOT:

Review Comment:
   You are right. I think there are a few more cases we could optimize, like 
pure disjunctions of term queries on a single-valued field where we could just 
sum up counts. I was thinking of introducing these optimizations one at a time 
to keep changes easy to review and test.



-- 
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-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to