You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by cp...@apache.org on 2024/02/19 16:16:02 UTC

(solr) branch jira/solr-13350 updated (119db0f64a6 -> 4a46b6d85c6)

This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a change to branch jira/solr-13350
in repository https://gitbox.apache.org/repos/asf/solr.git


    from 119db0f64a6 Merge remote-tracking branch 'origin/main' into jira/solr-13350
     new 2201a7d7526 factor out SolrIndexSearcher.populateScoresIfNeeded method
     new 4a46b6d85c6 use factored out SolrIndexSearcher.populateScoresIfNeeded method on new code path too

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../org/apache/solr/search/SolrIndexSearcher.java  | 45 +++++++++++-----------
 1 file changed, 22 insertions(+), 23 deletions(-)


(solr) 01/02: factor out SolrIndexSearcher.populateScoresIfNeeded method

Posted by cp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch jira/solr-13350
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 2201a7d7526b3c39e135e06abfdf22e6b2cd6b45
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Mon Feb 19 16:04:42 2024 +0000

    factor out SolrIndexSearcher.populateScoresIfNeeded method
---
 .../org/apache/solr/search/SolrIndexSearcher.java  | 26 +++++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index 5db23a5d391..a7c9712c348 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -1738,6 +1738,19 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
     }
   }
 
+  private Relation populateScoresIfNeeded(
+      QueryCommand cmd, boolean needScores, TopDocs topDocs, Query query, ScoreMode scoreModeUsed)
+      throws IOException {
+    if (cmd.getSort() != null && !(cmd.getQuery() instanceof RankQuery) && needScores) {
+      TopFieldCollector.populateScores(topDocs.scoreDocs, this, query);
+    }
+    if (scoreModeUsed == ScoreMode.COMPLETE || scoreModeUsed == ScoreMode.COMPLETE_NO_SCORES) {
+      return TotalHits.Relation.EQUAL_TO;
+    } else {
+      return topDocs.totalHits.relation;
+    }
+  }
+
   /**
    * Helper method for extracting the {@link FieldDoc} sort values from a {@link TopFieldDocs} when
    * available and making the appropriate call to {@link QueryResult#setNextCursorMark} when
@@ -1901,14 +1914,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
 
         totalHits = topCollector.getTotalHits();
         topDocs = topCollector.topDocs(0, len);
-        if (scoreModeUsed == ScoreMode.COMPLETE || scoreModeUsed == ScoreMode.COMPLETE_NO_SCORES) {
-          hitsRelation = TotalHits.Relation.EQUAL_TO;
-        } else {
-          hitsRelation = topDocs.totalHits.relation;
-        }
-        if (cmd.getSort() != null && cmd.getQuery() instanceof RankQuery == false && needScores) {
-          TopFieldCollector.populateScores(topDocs.scoreDocs, this, query);
-        }
+        hitsRelation = populateScoresIfNeeded(cmd, needScores, topDocs, query, scoreModeUsed);
         populateNextCursorMarkFromTopDocs(qr, cmd, topDocs);
 
         maxScore =
@@ -2253,9 +2259,7 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
         assert (totalHits == set.size()) || qr.isPartialResults();
 
         topDocs = topCollector.topDocs(0, len);
-        if (cmd.getSort() != null && !(cmd.getQuery() instanceof RankQuery) && needScores) {
-          TopFieldCollector.populateScores(topDocs.scoreDocs, this, query);
-        }
+        populateScoresIfNeeded(cmd, needScores, topDocs, query, ScoreMode.COMPLETE);
         populateNextCursorMarkFromTopDocs(qr, cmd, topDocs);
         maxScore =
             totalHits > 0


(solr) 02/02: use factored out SolrIndexSearcher.populateScoresIfNeeded method on new code path too

Posted by cp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch jira/solr-13350
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 4a46b6d85c66ca2b34a5c8a365ac3087221c0a11
Author: Christine Poerschke <cp...@apache.org>
AuthorDate: Mon Feb 19 16:13:42 2024 +0000

    use factored out SolrIndexSearcher.populateScoresIfNeeded method on new code path too
---
 .../org/apache/solr/search/SolrIndexSearcher.java     | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
index a7c9712c348..81ae9b08b8c 100644
--- a/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
+++ b/solr/core/src/java/org/apache/solr/search/SolrIndexSearcher.java
@@ -1943,16 +1943,9 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
         }
 
         populateNextCursorMarkFromTopDocs(qr, cmd, topDocs);
-        if (cmd.getSort() != null && !(cmd.getQuery() instanceof RankQuery) && needScores) {
-          TopFieldCollector.populateScores(topDocs.scoreDocs, this, query);
-        }
+        hitsRelation =
+            populateScoresIfNeeded(cmd, needScores, topDocs, query, searchResult.scoreMode);
         nDocsReturned = topDocs.scoreDocs.length;
-        ScoreMode scoreModeUsed = searchResult.scoreMode;
-        if (scoreModeUsed == ScoreMode.COMPLETE || scoreModeUsed == ScoreMode.COMPLETE_NO_SCORES) {
-          hitsRelation = TotalHits.Relation.EQUAL_TO;
-        } else {
-          hitsRelation = topDocs.totalHits.relation;
-        }
       }
 
       ids = new int[nDocsReturned];
@@ -2292,9 +2285,11 @@ public class SolrIndexSearcher extends IndexSearcher implements Closeable, SolrI
         }
 
         populateNextCursorMarkFromTopDocs(qr, cmd, topDocs);
-        if (cmd.getSort() != null && !(cmd.getQuery() instanceof RankQuery) && needScores) {
-          TopFieldCollector.populateScores(topDocs.scoreDocs, this, query);
-        }
+        populateScoresIfNeeded(cmd, needScores, topDocs, query, ScoreMode.COMPLETE);
+        // TODO: Is this correct?
+        // hitsRelation = populateScoresIfNeeded(cmd, needScores, topDocs, query,
+        // searchResult.scoreMode);
+
         // nDocsReturned = topDocs.scoreDocs.length;
         // TODO: Is this correct?
         // hitsRelation = topDocs.totalHits.relation;