nit0906 commented on code in PR #1673:
URL: https://github.com/apache/jackrabbit-oak/pull/1673#discussion_r1741378045


##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndexPlanner.java:
##########
@@ -838,17 +841,29 @@ private int getMaxPossibleNumDocs(Map<String, 
PropertyDefinition> propDefns, Fil
             if (result.relPropMapping.containsKey(key)) {
                 key = getName(key);
             }
-            int docCntForField = indexStatistics.getDocCountFor(key);
+            PropertyRestriction pr = filter.getPropertyRestriction(key);
+            String fieldName = key;
+            // for "is not null" we can use an asterisk query
+            if (improvedIsNullCost) {
+                if (pr != null && pr.isNullRestriction()) {
+                    fieldName = FieldNames.NULL_PROPS;
+                }
+            }
+            int docCntForField = indexStatistics.getDocCountFor(fieldName);
             if (docCntForField == -1) {
                 continue;
             }
 
             int weight = propDef.getValue().weight;
 
-            PropertyRestriction pr = filter.getPropertyRestriction(key);
             if (pr != null) {
                 if (pr.isNotNullRestriction()) {
                     // don't use weight for "is not null" restrictions
+                    // as all documents with this field can match;
+                    weight = 1;
+                } else if (improvedIsNullCost && pr.isNullRestriction()) {
+                    // don't use the weight for "is not null" restrictions

Review Comment:
   did you mean 
   
   // don't use the weight for "is null" restrictions



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

Reply via email to