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

This commit is contained in:
jimczi 2019-04-05 17:06:57 +02:00
parent 926de465ee
commit 04c33c77bf
1 changed files with 3 additions and 1 deletions

View File

@ -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);
}