thomasmueller commented on code in PR #2912:
URL: https://github.com/apache/jackrabbit-oak/pull/2912#discussion_r3289187081
##########
oak-search/src/main/java/org/apache/jackrabbit/oak/plugins/index/search/spi/query/FulltextIndexPlanner.java:
##########
@@ -960,6 +977,116 @@ private int getMaxPossibleNumDocs(Map<String,
PropertyDefinition> propDefns, Fil
return minNumDocs;
}
+ /**
+ * OAK-12221: cost estimation using a multiplicative selectivity model.
+ * <p>
+ * Each indexed condition contributes a selectivity (the probability that
a document
+ * satisfies the condition, given it has the field): {@code mcvFraction}
for MCV matches,
+ * {@code 1/weight} when only a weight is known, and {@code 1.0} when
{@code weight == 1}.
+ * The combined selectivity is the product of all per-condition
selectivities, applied
+ * once at the end against the most restrictive field's doc count. This
makes the
+ * estimate independent of iteration order.
+ */
+ private int getMaxPossibleNumDocsBySelectivity(Map<String,
PropertyDefinition> propDefns, Filter filter) {
+ IndexStatistics indexStatistics = indexNode.getIndexStatistics();
+ if (indexStatistics == null) {
Review Comment:
it would be better to have unit tests, so that it is not needed to add
indexes, I agree... but that would require quite a big refactoring, which I'm
not sure if it's worth it currently...
--
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]