From 04c33c77bf87957156105bc387e0541f0342e471 Mon Sep 17 00:00:00 2001 From: jimczi Date: Fri, 5 Apr 2019 17:06:57 +0200 Subject: [PATCH] LUCENE-8701: force the score mode of the child weight to COMPLETE if the score is required --- .../org/apache/lucene/search/join/ToParentBlockJoinQuery.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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); }