You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ilaygit <gi...@git.apache.org> on 2018/05/11 09:06:17 UTC

[GitHub] lucene-solr pull request #300: SOLR-11831: Skip second grouping step if grou...

Github user ilaygit commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/300#discussion_r187560009
  
    --- Diff: 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) {
    --- End diff --
    
    SortField => getComparator(final int numHits, final int sortPos) .. differs in signature of the api..


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org