-
Notifications
You must be signed in to change notification settings - Fork 2.4k
fix issue 18446 NPE by making sure scoreSupplier.get() returns non-null scorer #19650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -124,72 +124,45 @@ public Weight createWeight(IndexSearcher searcher, ScoreMode scoreMode, float bo | |
| Weight subQueryWeight = subQuery.createWeight(searcher, subQueryScoreMode, 1.0f); | ||
|
|
||
| return new Weight(this) { | ||
|
|
||
cwperks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Override | ||
| public ScorerSupplier scorerSupplier(LeafReaderContext context) throws IOException { | ||
| final Weight weight = this; | ||
| ScorerSupplier subQueryScorerSupplier = subQueryWeight.scorerSupplier(context); | ||
| if (subQueryScorerSupplier == null) { | ||
| return null; | ||
| } | ||
|
Comment on lines
+130
to
+133
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensuring the |
||
| Weight weight = this; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I will probably decare |
||
| return new ScorerSupplier() { | ||
| private Scorer scorer; | ||
cwperks marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private BulkScorer bulkScorer; | ||
|
|
||
| @Override | ||
| public BulkScorer bulkScorer() throws IOException { | ||
| if (minScore == null) { | ||
| final BulkScorer subQueryBulkScorer = subQueryWeight.bulkScorer(context); | ||
| if (subQueryBulkScorer == null) { | ||
| bulkScorer = null; | ||
| } else { | ||
| bulkScorer = new ScriptScoreBulkScorer( | ||
| subQueryBulkScorer, | ||
| subQueryScoreMode, | ||
| makeScoreScript(context), | ||
| boost | ||
| ); | ||
| } | ||
| final BulkScorer subQueryBulkScorer = subQueryScorerSupplier.bulkScorer(); | ||
| return new ScriptScoreBulkScorer(subQueryBulkScorer, subQueryScoreMode, makeScoreScript(context), boost); | ||
| } else { | ||
| final Scorer scorer = get(Long.MAX_VALUE); | ||
| if (scorer != null) { | ||
| bulkScorer = new Weight.DefaultBulkScorer(scorer); | ||
| } | ||
| return super.bulkScorer(); | ||
| } | ||
|
|
||
| return bulkScorer; | ||
| } | ||
|
|
||
| @Override | ||
| public Scorer get(long leadCost) throws IOException { | ||
| final Scorer subQueryScorer = subQueryWeight.scorer(context); | ||
|
|
||
| if (subQueryScorer == null) { | ||
| scorer = null; | ||
| } else { | ||
| Scorer scriptScorer = new ScriptScorer( | ||
| weight, | ||
| makeScoreScript(context), | ||
| subQueryScorer, | ||
| subQueryScoreMode, | ||
| boost, | ||
| null | ||
| ); | ||
| if (minScore != null) { | ||
| scriptScorer = new MinScoreScorer(weight, scriptScorer, minScore); | ||
| } | ||
| scorer = scriptScorer; | ||
| Scorer subQueryScorer = subQueryScorerSupplier.get(leadCost); | ||
| Scorer scriptScorer = new ScriptScorer( | ||
| weight, | ||
| makeScoreScript(context), | ||
| subQueryScorer, | ||
| subQueryScoreMode, | ||
| boost, | ||
| null | ||
| ); | ||
| if (minScore != null) { | ||
| scriptScorer = new MinScoreScorer(weight, scriptScorer, minScore); | ||
| } | ||
|
|
||
| return scorer; | ||
| return scriptScorer; | ||
| } | ||
|
|
||
| @Override | ||
| public long cost() { | ||
| if (scorer != null) { | ||
| return scorer.iterator().cost(); | ||
| } else if (bulkScorer != null) { | ||
| return bulkScorer.cost(); | ||
| } else { | ||
| // We have no prior knowledge of how many docs might match for any given query term, | ||
| // so we assume that all docs could be a match. | ||
| return Integer.MAX_VALUE; | ||
| } | ||
| return subQueryScorerSupplier.cost(); | ||
| } | ||
| }; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not using the boost? Is it because the boost is irrelevant for the subQuery?