Skip to content

Commit

Permalink
iter
Browse files Browse the repository at this point in the history
  • Loading branch information
pmpailis committed Sep 11, 2024
1 parent a7935af commit 5d5fe89
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,15 +424,14 @@ private static SearchHits getHits(
) {
SortedTopDocs sortedTopDocs = reducedQueryPhase.sortedTopDocs;
int sortScoreIndex = -1;
int sortRankIndex = -1;
if (sortedTopDocs.isSortedByField) {
SortField[] sortFields = sortedTopDocs.sortFields;
for (int i = 0; i < sortFields.length; i++) {
if (sortFields[i].getType() == SortField.Type.SCORE) {
sortScoreIndex = i;
break;
} else if (RankDocsSortField.NAME.equals(sortFields[i].getField())) {
sortScoreIndex = i;
break;
sortRankIndex = i;
}
}
}
Expand Down Expand Up @@ -470,17 +469,15 @@ private static SearchHits getHits(
searchHit.setRank(((RankDoc) shardDoc).rank);
searchHit.score(shardDoc.score);
} else if (sortedTopDocs.isSortedByField) {
if (shardDoc instanceof FieldDoc) {
FieldDoc fieldDoc = (FieldDoc) shardDoc;
if (shardDoc instanceof FieldDoc fieldDoc) {
searchHit.sortValues(fieldDoc.fields, reducedQueryPhase.sortValueFormats);
if (sortScoreIndex != -1) {
searchHit.score(((Number) fieldDoc.fields[sortScoreIndex]).floatValue());
}
} else if (shardDoc instanceof RankDoc) {
RankDoc rankDoc = (RankDoc) shardDoc;
} else if (shardDoc instanceof RankDoc rankDoc) {
searchHit.sortValues(rankDoc.sortValues, reducedQueryPhase.sortValueFormats);
if (sortScoreIndex != -1) {
searchHit.score(RankDocsSortField.decodeScore((Long) rankDoc.sortValues[sortScoreIndex]));
if (sortRankIndex != -1) {
searchHit.score(RankDocsSortField.decodeScore((Long) rankDoc.sortValues[sortRankIndex]));
}
searchHit.setRank(rankDoc.rank);
} else {
Expand Down

0 comments on commit 5d5fe89

Please sign in to comment.