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


##########
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()) {

Review Comment:
   Yes, of course it's possible. I kept it separate on purpose: so that the 
conditions and the comments are easier to read. I think in this case having the 
more verbose "duplication" of one line is better than to combine the cases and 
have a complex condition and comment. But it's just a personal preference, I 
assume.



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