Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

LUCENE-8701: force the score mode of the child weight to COMPLETE if the score is required

jimczi04c33c77bf87
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
index 837fabd4747..d01c0196415 100644
--- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
@@ -106,7 +106,9 @@ public class ToParentBlockJoinQuery extends Query {
// query is not requested.
childWeight = searcher.rewrite(new ConstantScoreQuery(childQuery)).createWeight(searcher, weightScoreMode, 0f);
} else {
- childWeight = childQuery.createWeight(searcher, weightScoreMode.needsScores() ? COMPLETE : COMPLETE_NO_SCORES, boost);
+ // if the score is needed we force the collection mode to COMPLETE because the child query cannot skip
+ // non-competitive documents.
+ childWeight = childQuery.createWeight(searcher, weightScoreMode.needsScores() ? COMPLETE : weightScoreMode, boost);
}
return new BlockJoinWeight(this, childWeight, parentsFilter, childScoreMode);
}