// Sort by field ascending, order first
ToParentBlockJoinSortField sortField = new ToParentBlockJoinSortField(
"field2", SortField.Type.STRING, false, wrap(parentFilter), wrap(childFilter)
);
Sort sort = new Sort(sortField);
TopFieldDocs topDocs = searcher.search(query, 5, sort);
assertEquals(7, topDocs.totalHits);
assertEquals(5, topDocs.scoreDocs.length);
assertEquals(3, topDocs.scoreDocs[0].doc);
assertEquals("a", ((BytesRef) ((FieldDoc) topDocs.scoreDocs[0]).fields[0]).utf8ToString());
assertEquals(7, topDocs.scoreDocs[1].doc);