SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 2 of 2)

This commit is contained in:
Christine Poerschke 2016-09-26 12:27:12 +01:00
parent be4233cb56
commit a8f4ef02ed
1 changed files with 15 additions and 37 deletions

View File

@ -268,6 +268,7 @@ public class ReRankQParserPlugin extends QParserPlugin {
IntIntHashMap boostedDocs = QueryElevationComponent.getBoostDocs((SolrIndexSearcher)searcher, boostedPriority, requestContext);
Arrays.sort(rescoredDocs.scoreDocs, new BoostedComp(boostedDocs, mainDocs.scoreDocs, rescoredDocs.getMaxScore()));
}
if(howMany == rescoredDocs.scoreDocs.length) {
return rescoredDocs; // Just return the rescoredDocs
@ -285,29 +286,6 @@ public class ReRankQParserPlugin extends QParserPlugin {
rescoredDocs.scoreDocs = scoreDocs;
return rescoredDocs;
}
} else {
if(howMany == rescoredDocs.scoreDocs.length) {
return rescoredDocs; // Just return the rescoredDocs
} else if(howMany > rescoredDocs.scoreDocs.length) {
//We need to return more then we've reRanked, so create the combined page.
ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
//lay down the initial docs
System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length);
//overlay the rescoreds docs
System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);
rescoredDocs.scoreDocs = scoreDocs;
return rescoredDocs;
} else {
//We've rescored more then we need to return.
ScoreDoc[] scoreDocs = new ScoreDoc[howMany];
System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, howMany);
rescoredDocs.scoreDocs = scoreDocs;
return rescoredDocs;
}
}
} catch (Exception e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, e);
}