You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by cp...@apache.org on 2016/09/23 13:47:12 UTC

[2/3] lucene-solr:branch_6x: SOLR-9543: reduce code duplication in ReRankQParserPlugin.ReRankCollector.topDocs (part 1 of 2)

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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/35f20a9f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/35f20a9f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/35f20a9f

Branch: refs/heads/branch_6x
Commit: 35f20a9f4030a1a7c3adae0c83e6ce5c94bae579
Parents: 1d11d12
Author: Christine Poerschke <cp...@apache.org>
Authored: Thu Sep 22 18:23:29 2016 +0100
Committer: Christine Poerschke <cp...@apache.org>
Committed: Fri Sep 23 13:46:16 2016 +0100

----------------------------------------------------------------------
 .../apache/solr/search/ReRankQParserPlugin.java | 44 ++++++--------------
 1 file changed, 12 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/35f20a9f/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
index 2c00a20..da02ab6 100644
--- a/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
+++ b/solr/core/src/java/org/apache/solr/search/ReRankQParserPlugin.java
@@ -246,6 +246,18 @@ public class ReRankQParserPlugin extends QParserPlugin {
           return mainDocs;
         }
 
+        ScoreDoc[] mainScoreDocs = mainDocs.scoreDocs;
+        ScoreDoc[] reRankScoreDocs = new ScoreDoc[Math.min(mainScoreDocs.length, reRankDocs)];
+        System.arraycopy(mainScoreDocs, 0, reRankScoreDocs, 0, reRankScoreDocs.length);
+
+        mainDocs.scoreDocs = reRankScoreDocs;
+
+        TopDocs rescoredDocs = reRankQueryRescorer
+            .rescore(searcher, mainDocs, mainDocs.scoreDocs.length);
+
+        //Lower howMany to return if we've collected fewer documents.
+        howMany = Math.min(howMany, mainScoreDocs.length);
+
         if(boostedPriority != null) {
           SolrRequestInfo info = SolrRequestInfo.getRequestInfo();
           Map requestContext = null;
@@ -255,20 +267,8 @@ public class ReRankQParserPlugin extends QParserPlugin {
 
           IntIntHashMap boostedDocs = QueryElevationComponent.getBoostDocs((SolrIndexSearcher)searcher, boostedPriority, requestContext);
 
-          ScoreDoc[] mainScoreDocs = mainDocs.scoreDocs;
-          ScoreDoc[] reRankScoreDocs = new ScoreDoc[Math.min(mainScoreDocs.length, reRankDocs)];
-          System.arraycopy(mainScoreDocs,0,reRankScoreDocs,0,reRankScoreDocs.length);
-
-          mainDocs.scoreDocs = reRankScoreDocs;
-
-          TopDocs rescoredDocs = reRankQueryRescorer
-              .rescore(searcher, mainDocs, mainDocs.scoreDocs.length);
-
           Arrays.sort(rescoredDocs.scoreDocs, new BoostedComp(boostedDocs, mainDocs.scoreDocs, rescoredDocs.getMaxScore()));
 
-          //Lower howMany if we've collected fewer documents.
-          howMany = Math.min(howMany, mainScoreDocs.length);
-
           if(howMany == rescoredDocs.scoreDocs.length) {
             return rescoredDocs; // Just return the rescoredDocs
           } else if(howMany > rescoredDocs.scoreDocs.length) {
@@ -288,26 +288,6 @@ public class ReRankQParserPlugin extends QParserPlugin {
 
         } else {
 
-          ScoreDoc[] mainScoreDocs   = mainDocs.scoreDocs;
-
-          /*
-          *  Create the array for the reRankScoreDocs.
-          */
-          ScoreDoc[] reRankScoreDocs = new ScoreDoc[Math.min(mainScoreDocs.length, reRankDocs)];
-
-          /*
-          *  Copy the initial results into the reRankScoreDocs array.
-          */
-          System.arraycopy(mainScoreDocs, 0, reRankScoreDocs, 0, reRankScoreDocs.length);
-
-          mainDocs.scoreDocs = reRankScoreDocs;
-
-          TopDocs rescoredDocs = reRankQueryRescorer
-              .rescore(searcher, mainDocs, mainDocs.scoreDocs.length);
-
-          //Lower howMany to return if we've collected fewer documents.
-          howMany = Math.min(howMany, mainScoreDocs.length);
-
           if(howMany == rescoredDocs.scoreDocs.length) {
             return rescoredDocs; // Just return the rescoredDocs
           } else if(howMany > rescoredDocs.scoreDocs.length) {