fix a problem where max_score was NaN if there were no hits from a shard (though there are hits from other shards), it will still be NaN where there are no hits

This commit is contained in:
kimchy 2010-07-15 22:58:18 +03:00
parent cf998e2f89
commit 3006183191
1 changed files with 6 additions and 1 deletions

View File

@ -190,7 +190,12 @@ public class SearchPhaseController {
float maxScore = Float.NEGATIVE_INFINITY;
for (QuerySearchResultProvider queryResultProvider : queryResults.values()) {
totalHits += queryResultProvider.queryResult().topDocs().totalHits;
maxScore = Math.max(maxScore, queryResultProvider.queryResult().topDocs().getMaxScore());
if (!Float.isNaN(queryResultProvider.queryResult().topDocs().getMaxScore())) {
maxScore = Math.max(maxScore, queryResultProvider.queryResult().topDocs().getMaxScore());
}
}
if (Float.isInfinite(maxScore)) {
maxScore = Float.NaN;
}
// clean the fetch counter