@Override
    public Result search(Query query, Execution execution) {
        if ( ! query.properties().getBoolean(groupingFlatten, true)) return execution.search(query);
        if ( ! query.properties().getBoolean(flatten, true)) return execution.search(query);

        query.trace("Flattening groups", 2);
        int originalHits = query.getHits();
        query.setHits(0);
        Result result = execution.search(query);
        query.setHits(originalHits);
        flatten(result.hits(), 0, result);
        return result;
    }
Flattens a grouping result into a flat list of hits on the top level in the returned result.
Useful when using grouping to create hits with diversity and similar.

@author bratseth
container-search/src/main/java/com/yahoo/search/grouping/result/FlatteningSearcher.java