cpoerschke commented on a change in pull request #300: SOLR-11831: Skip second 
grouping step if group.limit is 1 (aka Las Vegas Patch)
URL: https://github.com/apache/lucene-solr/pull/300#discussion_r356061224
 
 

 ##########
 File path: 
lucene/grouping/src/java/org/apache/lucene/search/grouping/FirstPassGroupingCollector.java
 ##########
 @@ -132,17 +132,28 @@ public ScoreMode scoreMode() {
     final Collection<SearchGroup<T>> result = new ArrayList<>();
     int upto = 0;
     final int sortFieldCount = comparators.length;
+    assert sortFieldCount > 0; // this must always be true because fields Sort 
must contain at least a field
     for(CollectedSearchGroup<T> group : orderedGroups) {
       if (upto++ < groupOffset) {
         continue;
       }
       // System.out.println("  group=" + (group.groupValue == null ? "null" : 
group.groupValue.toString()));
       SearchGroup<T> searchGroup = new SearchGroup<>();
       searchGroup.groupValue = group.groupValue;
+      // We pass this around so that we can get the corresponding solr id when 
serializing the search group to send to the federator
+      searchGroup.topDocLuceneId = group.topDoc;
       searchGroup.sortValues = new Object[sortFieldCount];
       for(int sortFieldIDX=0;sortFieldIDX<sortFieldCount;sortFieldIDX++) {
         searchGroup.sortValues[sortFieldIDX] = 
comparators[sortFieldIDX].value(group.comparatorSlot);
       }
+      searchGroup.topDocScore = Float.NaN;
+      // if there is the score comparator we want to return the score
+      for (FieldComparator comparator: comparators){
+        if (comparator instanceof FieldComparator.RelevanceComparator){
+          searchGroup.topDocScore = 
(Float)comparator.value(group.comparatorSlot);
+        }
 
 Review comment:
   Taking the conversation back from the commits on the above branch to here: 
https://github.com/bloomberg/lucene-solr/pull/232 sketches extending Lucene's 
FirstPassGroupingCollector and SearchGroup for Solr's group.skip.second.step 
use as outlined above.
   
   Flagged up by that sketching, and not yet fully explored, is the question of 
whether or not the exclusion of group.func is actually needed, superficially it 
seemed it might not be i.e. the federator is just merging groups and sorting by 
id(s) and where the ids came from might not matter.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to