|
22 | 22 | import org.opensearch.action.search.SearchPhaseContext;
|
23 | 23 | import org.opensearch.common.lucene.search.TopDocsAndMaxScore;
|
24 | 24 | import org.opensearch.neuralsearch.processor.combination.CombineScoresDto;
|
25 |
| -import org.opensearch.neuralsearch.processor.combination.ScoreCombinationTechnique; |
26 | 25 | import org.opensearch.neuralsearch.processor.combination.ScoreCombiner;
|
27 | 26 | import org.opensearch.neuralsearch.processor.explain.CombinedExplanationDetails;
|
28 | 27 | import org.opensearch.neuralsearch.processor.explain.DocIdAtSearchShard;
|
29 | 28 | import org.opensearch.neuralsearch.processor.explain.ExplanationDetails;
|
30 | 29 | import org.opensearch.neuralsearch.processor.explain.ExplainableTechnique;
|
31 | 30 | import org.opensearch.neuralsearch.processor.explain.ExplanationPayload;
|
32 |
| -import org.opensearch.neuralsearch.processor.normalization.ScoreNormalizationTechnique; |
33 | 31 | import org.opensearch.neuralsearch.processor.normalization.ScoreNormalizer;
|
34 | 32 | import org.opensearch.search.SearchHit;
|
35 | 33 | import org.opensearch.search.SearchHits;
|
@@ -57,44 +55,30 @@ public class NormalizationProcessorWorkflow {
|
57 | 55 |
|
58 | 56 | /**
|
59 | 57 | * Start execution of this workflow
|
60 |
| - * @param querySearchResults input data with QuerySearchResult from multiple shards |
61 |
| - * @param normalizationTechnique technique for score normalization |
62 |
| - * @param combinationTechnique technique for score combination |
| 58 | + * @param request contains querySearchResults input data with QuerySearchResult |
| 59 | + * from multiple shards, fetchSearchResultOptional, normalizationTechnique technique for score normalization |
| 60 | + * combinationTechnique technique for score combination, and nullable rankConstant only used in RRF technique |
63 | 61 | */
|
64 |
| - public void execute( |
65 |
| - final List<QuerySearchResult> querySearchResults, |
66 |
| - final Optional<FetchSearchResult> fetchSearchResultOptional, |
67 |
| - final ScoreNormalizationTechnique normalizationTechnique, |
68 |
| - final ScoreCombinationTechnique combinationTechnique, |
69 |
| - final SearchPhaseContext searchPhaseContext |
70 |
| - ) { |
71 |
| - NormalizationProcessorWorkflowExecuteRequest request = NormalizationProcessorWorkflowExecuteRequest.builder() |
72 |
| - .querySearchResults(querySearchResults) |
73 |
| - .fetchSearchResultOptional(fetchSearchResultOptional) |
74 |
| - .normalizationTechnique(normalizationTechnique) |
75 |
| - .combinationTechnique(combinationTechnique) |
76 |
| - .explain(false) |
77 |
| - .searchPhaseContext(searchPhaseContext) |
78 |
| - .build(); |
79 |
| - execute(request); |
80 |
| - } |
81 |
| - |
82 | 62 | public void execute(final NormalizationProcessorWorkflowExecuteRequest request) {
|
83 | 63 | List<QuerySearchResult> querySearchResults = request.getQuerySearchResults();
|
84 | 64 | Optional<FetchSearchResult> fetchSearchResultOptional = request.getFetchSearchResultOptional();
|
85 |
| - |
86 |
| - // save original state |
87 |
| - List<Integer> unprocessedDocIds = unprocessedDocIds(querySearchResults); |
| 65 | + List<Integer> unprocessedDocIds = unprocessedDocIds(request.getQuerySearchResults()); |
88 | 66 |
|
89 | 67 | // pre-process data
|
90 | 68 | log.debug("Pre-process query results");
|
91 | 69 | List<CompoundTopDocs> queryTopDocs = getQueryTopDocs(querySearchResults);
|
92 | 70 |
|
93 | 71 | explain(request, queryTopDocs);
|
94 | 72 |
|
| 73 | + // Data transfer object for score normalization used to pass nullable rankConstant which is only used in RRF |
| 74 | + NormalizeScoresDTO normalizeScoresDTO = NormalizeScoresDTO.builder() |
| 75 | + .queryTopDocs(queryTopDocs) |
| 76 | + .normalizationTechnique(request.getNormalizationTechnique()) |
| 77 | + .build(); |
| 78 | + |
95 | 79 | // normalize
|
96 | 80 | log.debug("Do score normalization");
|
97 |
| - scoreNormalizer.normalizeScores(queryTopDocs, request.getNormalizationTechnique()); |
| 81 | + scoreNormalizer.normalizeScores(normalizeScoresDTO); |
98 | 82 |
|
99 | 83 | CombineScoresDto combineScoresDTO = CombineScoresDto.builder()
|
100 | 84 | .queryTopDocs(queryTopDocs)
|
|
0 commit comments