Skip to content

Commit

Permalink
Fixed exception for explain in hybrid query when partial match in sub…
Browse files Browse the repository at this point in the history
…queries

Signed-off-by: Martin Gaievski <gaievski@amazon.com>
  • Loading branch information
martin-gaievski committed Jan 18, 2025
1 parent 660f577 commit 33d590b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,17 @@ public SearchResponse processResponse(
ExplanationDetails normalizationExplanation = combinedExplainDetail.getNormalizationExplanations();
ExplanationDetails combinationExplanation = combinedExplainDetail.getCombinationExplanations();
// Create normalized explanations for each detail
Explanation[] normalizedExplanation = new Explanation[queryLevelExplanation.getDetails().length];
List<Explanation> normalizedExplanation = new ArrayList<>();
for (int i = 0; i < queryLevelExplanation.getDetails().length; i++) {
normalizedExplanation[i] = Explanation.match(
// normalized score
normalizationExplanation.getScoreDetails().get(i).getKey(),
// description of normalized score
normalizationExplanation.getScoreDetails().get(i).getValue(),
// shard level details
queryLevelExplanation.getDetails()[i]
normalizedExplanation.add(
Explanation.match(
// normalized score
normalizationExplanation.getScoreDetails().get(i).getKey(),
// description of normalized score
normalizationExplanation.getScoreDetails().get(i).getValue(),
// shard level details
queryLevelExplanation.getDetails()[i]
)
);
}
// Create and set final explanation combining all components
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ public Explanation explain(LeafReaderContext context, int doc) throws IOExceptio
subsOnMatch.add(e);
max = Math.max(max, score);
} else if (!match) {
subsOnMatch.add(e);
subsOnNoMatch.add(e);
}
}
Expand Down

0 comments on commit 33d590b

Please sign in to comment.