Repository navigation
fix: guard ranking script_score against zero-match segments (Lucene 10 NPE) - #33292
Conversation
…0 NPE) On Lucene 10 (OpenSearch 3.x), a script_score whose inner query matches zero documents on a segment returns a null sub-scorer, which DisjunctionMaxScorer/DisiWrapper rejects with a NullPointerException. Wrapped in dis_max with allow_partial_search_results=true, the failing shard is silently dropped and search returns 0 results even though the matching document exists (open-metadata#33167). Wrap the inner query in a single-clause bool[should, minimumShouldMatch=1] so a zero-match segment yields a well-defined empty iterator instead of null. Scoring is unchanged: a single-clause bool with no must/filter scores exactly its clause.
❌ PR checklist incompleteThis PR cannot be merged until the following are addressed on its linked issue:
The fields live on the linked issue in the Shipping project (open the issue → right sidebar → Projects). After you set them, re-run this check (or push a commit) — issue/project changes do not re-trigger it automatically. Maintainers can bypass this check by adding the |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
|
Hi there 👋 Thanks for your contribution! The OpenMetadata team will review the PR shortly! Once it has been labeled as Let us know if you need any help! |
Code Review ✅ ApprovedFixes a Lucene 10 NPE in OptionsDisplay: compact → Counting what did not apply, without listing it. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Powered by Gitar — free for open source |
38cbdf9
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
|
🤖 Backport to |
…0 NPE) (#33292) (#33317) On Lucene 10 (OpenSearch 3.x), a script_score whose inner query matches zero documents on a segment returns a null sub-scorer, which DisjunctionMaxScorer/DisiWrapper rejects with a NullPointerException. Wrapped in dis_max with allow_partial_search_results=true, the failing shard is silently dropped and search returns 0 results even though the matching document exists (#33167). Wrap the inner query in a single-clause bool[should, minimumShouldMatch=1] so a zero-match segment yields a well-defined empty iterator instead of null. Scoring is unchanged: a single-clause bool with no must/filter scores exactly its clause. (cherry picked from commit 38cbdf9) Co-authored-by: Arvin <[email protected]> Co-authored-by: Sriharsha Chintalapani <[email protected]> Co-authored-by: Mohit Yadav <[email protected]>
Describe your changes:
Fixes #33167
On Lucene 10 (OpenSearch 3.3.x), a
script_scorewhose inner query matches zero documents on a segment returns a null sub-scorer.DisjunctionMaxScorer→DisiWrapper→Objects.requireNonNullthen throws an NPE. Combined withallow_partial_search_results=true(the default), the failing shard is silently dropped and the search endpoint returns HTTP 200 withhits.total.value = 0even though the matching document exists.The ranking matchers (
ranking:fuzzyName,ranking:partialName,ranking:structuralContext,ranking:descriptionContext) all go throughscriptScoreQuery, so every text ranking stage is exposed.Fix
Wrap the inner query of
scriptScoreQueryin a single-clausebool[should, minimumShouldMatch=1]. A zero-match segment then yields a well-defined empty iterator instead of null, so no scorer ever sees a null sub-iterator.Scoring is unchanged: a single-clause bool with no must/filter scores exactly its clause, and the
_name/matched_queriesbehavior the Ranking Details panel reads is preserved (the query name lives on the inner multi_match, inside the wrapper).Applied to both
OpenSearchQueryBuilderandElasticQueryBuilder(issue only observed on Lucene 10 / OpenSearch 3.3.2, but the guard is harmless and symmetric on ES).Type of change:
Notes:
SearchSourceBuilderFactoryTest) assert on the saturation script and stage query names, both preserved inside the wrapper — no test shape changes.