Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
pmpailis committed Oct 4, 2024
1 parent 0ed5b3b commit cd2e0b3
Showing 1 changed file with 3 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.elasticsearch.search.sort.FieldSortBuilder;
import org.elasticsearch.search.sort.NestedSortBuilder;
import org.elasticsearch.search.sort.ScoreSortBuilder;
import org.elasticsearch.search.sort.ShardDocSortField;
import org.elasticsearch.search.sort.SortBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.elasticsearch.test.ESIntegTestCase;
Expand Down Expand Up @@ -680,22 +681,14 @@ private RankDoc[] getRankDocs(SearchResponse searchResponse) {
for (int i = 0; i < size; i++) {
var hit = searchResponse.getHits().getAt(i);
long sortValue = (long) hit.getRawSortValues()[hit.getRawSortValues().length - 1];
int doc = decodeDoc(sortValue);
int shardRequestIndex = decodeShardRequestIndex(sortValue);
int doc = ShardDocSortField.decodeDoc(sortValue);
int shardRequestIndex = ShardDocSortField.decodeShardRequestIndex(sortValue);
docs[i] = new RankDoc(doc, hit.getScore(), shardRequestIndex);
docs[i].rank = i + 1;
}
return docs;
}

public static int decodeDoc(long value) {
return (int) value;
}

public static int decodeShardRequestIndex(long value) {
return (int) (value >> 32);
}

record RankDocAndHitRatio(RankDoc rankDoc, float hitRatio) {}

/**
Expand Down

0 comments on commit cd2e0b3

Please sign in to comment.