mirror of
https://github.com/apache/lucene.git
synced 2025-02-08 11:05:29 +00:00
SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 2 of 2)
This commit is contained in:
parent
11a98a89fd
commit
4534c7dd1a
@ -268,45 +268,23 @@ 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
|
||||
} 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];
|
||||
System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length); //lay down the initial docs
|
||||
System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);//overlay the re-ranked docs.
|
||||
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;
|
||||
}
|
||||
|
||||
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];
|
||||
System.arraycopy(mainScoreDocs, 0, scoreDocs, 0, scoreDocs.length); //lay down the initial docs
|
||||
System.arraycopy(rescoredDocs.scoreDocs, 0, scoreDocs, 0, rescoredDocs.scoreDocs.length);//overlay the re-ranked docs.
|
||||
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;
|
||||
}
|
||||
//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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user