@Test
    void testResultsFromMultipleDocumentTypes() {
        Query query = newQuery();
        GroupingRequest request = GroupingRequest.newInstance(query);
        request.setRootOperation(GroupingOperation.fromString("all(group(foo) each(output(min(bar), max(bar))))"));

        Map<String, List<GroupingListHit>> resultsByDocumentType = new HashMap<>();
        Grouping groupA1 = new Grouping(0);
        groupA1.setRoot(new com.yahoo.searchlib.aggregation.Group()
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(6)).setTag(4)))
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4)))
        );
        Grouping groupA2 = new Grouping(0);
        groupA2.setRoot(new com.yahoo.searchlib.aggregation.Group()
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueB")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(9)).setTag(4)))
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MinAggregationResult().setMin(new IntegerResultNode(6)).setTag(3)))
        );
        Grouping groupB1 = new Grouping(0);
        groupB1.setRoot(new com.yahoo.searchlib.aggregation.Group()
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueA")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(2)).setTag(4)))
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(3)).setTag(4)))
        );
        Grouping groupB2 = new Grouping(0);
        groupB2.setRoot(new com.yahoo.searchlib.aggregation.Group()
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("uniqueC")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(7)).setTag(4)))
                .addChild(new com.yahoo.searchlib.aggregation.Group().setId(new StringResultNode("common")).addAggregationResult(new MaxAggregationResult().setMax(new IntegerResultNode(11)).setTag(4)))
        );
        resultsByDocumentType.put("typeA", List.of(new GroupingListHit(List.of(groupA1), null, query),
                new GroupingListHit(List.of(groupA2), null, query)));
        resultsByDocumentType.put("typeB", List.of(new GroupingListHit(List.of(groupB1), null, query),
                new GroupingListHit(List.of(groupB2), null, query)));
        Execution execution = newExecution(new GroupingExecutor(),
                new MockClusterSearcher(),
                new MultiDocumentTypeResultProvider(resultsByDocumentType));

        Result result = execution.search(query);
        Group group = request.getResultGroup(result);
        assertEquals(1, group.size());
        Hit hit = group.get(0);
        assertInstanceOf(GroupList.class, hit);
        GroupList list = (GroupList) hit;

        assertEquals(4, list.size());

        assertNotNull(hit = list.get("group:string:uniqueA"));
        assertEquals(6L, hit.getField("max(bar)"));

        assertNotNull(hit = list.get("group:string:uniqueB"));
        assertEquals(9L, hit.getField("max(bar)"));

        assertNotNull(hit = list.get("group:string:common"));
        assertEquals(11L, hit.getField("max(bar)"));

        assertNotNull(hit = list.get("group:string:common"));
        assertEquals(6L, hit.getField("min(bar)"));
    }
Tests the internal rewriting of rank properties which happens in the query.prepare() call
(triggered by the exc.search call in the below).
container-search/src/test/java/com/yahoo/search/grouping/vespa/GroupingExecutorTestCase.java