@Test
    void testNoCollapsingIfNotAskedTo() {
        // Set up
        Map<Searcher, Searcher> chained = new HashMap<>();
        FieldCollapsingSearcher collapse = new FieldCollapsingSearcher();
        DocumentSourceSearcher docsource = new DocumentSourceSearcher();
        chained.put(collapse, docsource);

        Query q = new Query("?query=test_collapse");
        Result r = new Result(q);
        r.hits().add(createHitAmid("http://acme.org/a.html", 10, 0));
        r.hits().add(createHitAmid("http://acme.org/b.html", 9, 0));
        r.hits().add(createHitAmid("http://acme.org/c.html", 9, 1));
        r.hits().add(createHitAmid("http://acme.org/d.html", 8, 1));
        r.hits().add(createHitAmid("http://acme.org/e.html", 8, 2));
        r.hits().add(createHitAmid("http://acme.org/f.html", 7, 2));
        r.hits().add(createHitAmid("http://acme.org/g.html", 7, 3));
        r.hits().add(createHitAmid("http://acme.org/h.html", 6, 3));
        r.setTotalHitCount(8);
        docsource.addResult(q, r);

        // Test that no collapsing occured
        q = new Query("?query=test_collapse");
        r = doSearch(collapse, q, 0, 10, chained);

        assertEquals(8, r.getHitCount());
        assertEquals(1, docsource.getQueryCount());
    }
Test that collapsing works if multiple searches are necessary.
container-search/src/test/java/com/yahoo/prelude/searcher/test/FieldCollapsingSearcherTestCase.java