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 <[email protected]>
  • Loading branch information
martin-gaievski committed Jan 18, 2025
1 parent 660f577 commit 79f6a58
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.lucene.search.Explanation;
import org.opensearch.action.search.SearchRequest;
import org.opensearch.action.search.SearchResponse;
Expand Down Expand Up @@ -101,11 +102,12 @@ public SearchResponse processResponse(
// Create normalized explanations for each detail
Explanation[] normalizedExplanation = new Explanation[queryLevelExplanation.getDetails().length];
for (int i = 0; i < queryLevelExplanation.getDetails().length; i++) {
Pair<Float, String> scoreDetail = normalizationExplanation.getScoreDetails().get(0);
normalizedExplanation[i] = Explanation.match(
// normalized score
normalizationExplanation.getScoreDetails().get(i).getKey(),
scoreDetail.getKey(),
// description of normalized score
normalizationExplanation.getScoreDetails().get(i).getValue(),
scoreDetail.getValue(),
// shard level details
queryLevelExplanation.getDetails()[i]
);
Expand Down

0 comments on commit 79f6a58

Please sign in to comment.