You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by GitBox <gi...@apache.org> on 2022/06/10 06:03:49 UTC

[GitHub] [lucene] LuXugang commented on a diff in pull request #950: LUCENE-10608: Implement Weight#count on pure conjunctions.

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


##########
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:
+        case SHOULD:

Review Comment:
   If `weightedClauses.size() == 1`, and this clause's occur is `SHOULD`, we could also leverage `Weight#count`, should we need to specialize this case?



-- 
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