gautamworah96 commented on a change in pull request #242:
URL: https://github.com/apache/lucene/pull/242#discussion_r690844493



##########
File path: lucene/core/src/java/org/apache/lucene/search/Weight.java
##########
@@ -174,6 +174,31 @@ public BulkScorer bulkScorer(LeafReaderContext context) 
throws IOException {
     return new DefaultBulkScorer(scorer);
   }
 
+  /**
+   * Counts the number of documents that match a given {@link 
Weight#parentQuery} in a leaf. The

Review comment:
       Sure. Fixed it in 3d876d0

##########
File path: lucene/core/src/java/org/apache/lucene/search/IndexSearcher.java
##########
@@ -414,37 +414,13 @@ public int count(Query query) throws IOException {
       }
     }
 
-    // some counts can be computed in constant time
-    if (query instanceof MatchAllDocsQuery) {
-      return reader.numDocs();
-    } else if (query instanceof TermQuery && reader.hasDeletions() == false) {
-      Term term = ((TermQuery) query).getTerm();
-      int count = 0;
-      for (LeafReaderContext leaf : reader.leaves()) {
-        count += leaf.reader().docFreq(term);
-      }
-      return count;
+    final Weight weight = createWeight(query, ScoreMode.COMPLETE_NO_SCORES, 1);
+    int count = 0;
+    for (LeafReaderContext leafReaderContext : leafContexts) {

Review comment:
       Note: This method is probably slower than the pre-existing one because 
it is not slice-level multithreaded like the previous one




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