sijuv commented on code in PR #3222:
URL: https://github.com/apache/solr/pull/3222#discussion_r2017841694


##########
solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java:
##########
@@ -1984,18 +1982,22 @@ public ScoreMode scoreMode() {
       populateNextCursorMarkFromTopDocs(qr, cmd, topDocs);
 
       nDocsReturned = topDocs.scoreDocs.length;
-      ids = new int[nDocsReturned];
-      scores = needScores ? new float[nDocsReturned] : null;
-      for (int i = 0; i < nDocsReturned; i++) {
-        ScoreDoc scoreDoc = topDocs.scoreDocs[i];
-        ids[i] = scoreDoc.doc;
-        if (scores != null) scores[i] = scoreDoc.score;
+      int sliceLen = Math.min(lastDocRequested, nDocsReturned);
+      if (sliceLen < 0) {
+        sliceLen = 0;
+      }
+      if (!needScores) {
+        int[] ids = new int[nDocsReturned];
+        for (int i = 0; i < nDocsReturned; i++) {
+          ScoreDoc scoreDoc = topDocs.scoreDocs[i];
+          ids[i] = scoreDoc.doc;
+        }
+        docList = new DocSlice(0, sliceLen, ids, null, totalHits, maxScore, 
hitsRelation);
+      } else {
+        docList = new TopDocsSlice(0, sliceLen, topDocs, totalHits, maxScore, 
hitsRelation);
       }

Review Comment:
   yes we could. however I was not sure if there are places where we don't need 
scores and we dont use the `DocTransformer` to populate the results.  Esp since 
`needScores` was based on a condition which was not a function of requested 
fields.
   
   `    final boolean needScores = (cmd.getFlags() & GET_SCORES) != 0;
   `



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@solr.apache.org
For additional commands, e-mail: issues-h...@solr.apache.org

Reply via email to