iprithv commented on code in PR #16111:
URL: https://github.com/apache/lucene/pull/16111#discussion_r3357595770


##########
lucene/core/src/java/org/apache/lucene/search/FieldExistsQuery.java:
##########
@@ -234,22 +234,43 @@ public int count(LeafReaderContext context) throws 
IOException {
 
           return super.count(context);
         } else if (fieldInfo.hasVectorValues()) { // the field indexes vectors
+          int vectorCount = getVectorValuesSize(fieldInfo, reader);
+          if (vectorCount == reader.maxDoc()) {
+            // All docs have vectors, so the count is just the number of live 
docs.
+            return reader.numDocs();
+          }
           if (reader.hasDeletions() == false) {
-            return getVectorValuesSize(fieldInfo, reader);
+            return vectorCount;
           }
           return super.count(context);
         } else if (fieldInfo.getDocValuesType()
             != DocValuesType.NONE) { // the field indexes doc values
-          if (reader.hasDeletions() == false) {
+          if (fieldInfo.docValuesSkipIndexType() != 
DocValuesSkipIndexType.NONE) {
+            // DocValuesSkipper provides an exact doc count for doc values, so 
we can use it
+            // reliably even in the presence of deletions.

Review Comment:
   ah yeah, updated the comment. thanks!



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

Reply via email to