Skip to content

Commit 74da88c

Browse files
committed
cleaned up linearretrieverbuilder
1 parent d6a4928 commit 74da88c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

x-pack/plugin/rank-rrf/src/main/java/org/elasticsearch/xpack/rank/linear/LinearRetrieverBuilder.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ protected SearchSourceBuilder finalizeSourceBuilder(SearchSourceBuilder sourceBu
155155
}
156156

157157
@Override
158-
protected RankDoc[] combineInnerRetrieverResults(List<ScoreDoc[]> rankResults, boolean explain) {
158+
protected RankDoc[] combineInnerRetrieverResults(List<ScoreDoc[]> rankResults, boolean isExplain) {
159159
Map<RankDoc.RankKey, LinearRankDoc> docsToRankResults = Maps.newMapWithExpectedSize(rankWindowSize);
160160
final String[] normalizerNames = Arrays.stream(normalizers).map(ScoreNormalizer::getName).toArray(String[]::new);
161161
for (int result = 0; result < rankResults.size(); result++) {
@@ -169,7 +169,7 @@ protected RankDoc[] combineInnerRetrieverResults(List<ScoreDoc[]> rankResults, b
169169
LinearRankDoc rankDoc = docsToRankResults.computeIfAbsent(
170170
new RankDoc.RankKey(originalScoreDocs[scoreDocIndex].doc, originalScoreDocs[scoreDocIndex].shardIndex),
171171
key -> {
172-
if (explain) {
172+
if (isExplain) {
173173
LinearRankDoc doc = new LinearRankDoc(key.doc(), 0f, key.shardIndex(), weights, normalizerNames);
174174
doc.normalizedScores = new float[rankResults.size()];
175175
return doc;
@@ -178,7 +178,7 @@ protected RankDoc[] combineInnerRetrieverResults(List<ScoreDoc[]> rankResults, b
178178
}
179179
}
180180
);
181-
if (explain) {
181+
if (isExplain) {
182182
rankDoc.normalizedScores[result] = normalizedScoreDocs[scoreDocIndex].score;
183183
}
184184
// if we do not have scores associated with this result set, just ignore its contribution to the final
@@ -193,12 +193,10 @@ protected RankDoc[] combineInnerRetrieverResults(List<ScoreDoc[]> rankResults, b
193193
// sort the results based on the final score, tiebreaker based on smaller doc id
194194
LinearRankDoc[] sortedResults = docsToRankResults.values().toArray(LinearRankDoc[]::new);
195195
Arrays.sort(sortedResults);
196-
197196
int validCount = 0;
198197
while (validCount < sortedResults.length && sortedResults[validCount].score >= minScore) {
199198
validCount++;
200199
}
201-
202200
// trim the results to the minimum of rankWindowSize and the number of valid results
203201
int finalSize = Math.min(rankWindowSize, validCount);
204202
LinearRankDoc[] topResults = new LinearRankDoc[finalSize];

0 commit comments

Comments
 (0)