Skip to content

Commit

Permalink
Fix issue with maxscore
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoceccarelli committed Apr 24, 2019
1 parent 3f8831d commit 90dea50
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static <T> TopGroups<T> merge(TopGroups<T>[] shardGroups, Sort groupSort,
for(int groupIDX=0;groupIDX<numGroups;groupIDX++) {
final T groupValue = shardGroups[0].groups[groupIDX].groupValue;
//System.out.println(" merge groupValue=" + groupValue + " sortValues=" + Arrays.toString(shardGroups[0].groups[groupIDX].groupSortValues));
float maxScore = Float.MIN_VALUE;
float maxScore = Float.NaN;
int totalHits = 0;
double scoreSum = 0.0;
for(int shardIDX=0;shardIDX<shardGroups.length;shardIDX++) {
Expand Down Expand Up @@ -169,9 +169,13 @@ public static <T> TopGroups<T> merge(TopGroups<T>[] shardGroups, Sort groupSort,
shardGroupDocs.scoreDocs,
docSort.getSort());
}
if (! Float.isNaN(shardGroupDocs.maxScore)){
if (Float.isNaN(maxScore)){
maxScore = shardGroupDocs.maxScore;
}
else if (! Float.isNaN(shardGroupDocs.maxScore)){
maxScore = Math.max(maxScore, shardGroupDocs.maxScore);
}

assert shardGroupDocs.totalHits.relation == Relation.EQUAL_TO;
totalHits += shardGroupDocs.totalHits.value;
scoreSum += shardGroupDocs.score;
Expand Down

0 comments on commit 90dea50

Please sign in to comment.