You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ji...@apache.org on 2019/04/05 15:27:29 UTC
[lucene-solr] branch branch_8x updated: LUCENE-8701: force the
score mode of the child weight to COMPLETE if the score is required
This is an automated email from the ASF dual-hosted git repository.
jimczi pushed a commit to branch branch_8x
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/branch_8x by this push:
new 1fc215a LUCENE-8701: force the score mode of the child weight to COMPLETE if the score is required
1fc215a is described below
commit 1fc215ac53f1f8b8d7ee3d8c8b0ae55dfaf29bf3
Author: jimczi <ji...@apache.org>
AuthorDate: Fri Apr 5 17:06:57 2019 +0200
LUCENE-8701: force the score mode of the child weight to COMPLETE if the score is required
---
.../java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java | 6 +++++-
1 file changed, 5 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 dfb4e8e..f924179 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
@@ -39,6 +39,8 @@ import org.apache.lucene.search.TwoPhaseIterator;
import org.apache.lucene.search.Weight;
import org.apache.lucene.util.BitSet;
+import static org.apache.lucene.search.ScoreMode.COMPLETE;
+
/**
* This query requires that you index
* children and parent docs as a single block, using the
@@ -103,7 +105,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, 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);
}