diegoceccarelli 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_r257259551
 
 

 ##########
 File path: 
solr/core/src/java/org/apache/solr/handler/component/QueryComponent.java
 ##########
 @@ -233,6 +233,41 @@ public void prepare(ResponseBuilder rb) throws IOException
     }
   }
 
+  private boolean allowSkipSecondGroupingStep(final GroupingSpecification 
groupingSpec, final boolean isReranking ) {
+    // Only possible if we only want one doc per group
+    if (groupingSpec.getGroupLimit() != 1) {
+        logger.error("group.skip.second.step=true is not compatible with 
group.limit == " + groupingSpec.getGroupLimit() );
+        return false;
+    }
+
+    // Within group sort must be the same as group sort because if we skip 
second step no sorting within group will be done.
+    if (groupingSpec.getSortWithinGroup() !=  groupingSpec.getGroupSort()) {
+        logger.error("group.skip.second.step=true is not compatible with 
group.sort != sort");
+        return false;
+    }
+
+    boolean byRelevanceOnly = false;
+    SortField[] sortFields = groupingSpec.getGroupSort().getSort();
+
+    if(sortFields != null && sortFields.length == 1 && sortFields[0] != null 
&& sortFields[0].getComparator() instanceof 
FieldComparator.RelevanceComparator) {
+      byRelevanceOnly = true;
+    }
+
+    // TODO: At the moment the optimization is only supported when we are 
sorting by relevance only
+    if(!byRelevanceOnly) {
+        logger.error("group.skip.second.step=true is not compatible with sort= 
" + (sortFields != null? sortFields.toString() : null));
+        return false;
+    }
+
+    // TODO: At the moment the optimization does not support reranking
+    if(isReranking) {
 
 Review comment:
   yes! if this PR gets accepted, we will submit another one on LTR 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to