static GroupingOperation buildGroupingExpression(String dedupField, int groupingHits, String summaryClass,
                                                     Sorting sortSpec) {
        if (sortSpec != null) {
            return buildGroupingExpressionWithSorting(dedupField, groupingHits, summaryClass, sortSpec);
        } else {
            return buildGroupingExpressionWithRanking(dedupField, groupingHits, summaryClass);
        }
    }
Get all the hits returned by the grouping request. This might be more or less than the user requested.
This method handles the results from two different types of grouping expression, depending on whether
sorting was used for the query or not.

@param resultGroups The result group of the dedup grouping request
@return A (correctly sorted) list of all the hits returned by the grouping expression.
container-search/src/main/java/com/yahoo/search/grouping/UniqueGroupingSearcher.java