w.addDocuments(Arrays.asList(childDoc, parentDoc));
IndexReader r = w.getReader();
w.close();
IndexSearcher s = newSearcher(r, false);
Query tq = new TermQuery(new Term("child", "1"));
final Filter parentsFilter = new CachingWrapperFilter(new RawTermFilter(new Term("parent", "1")),
CachingWrapperFilter.DeletesMode.IGNORE);
ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentsFilter, ToParentBlockJoinQuery.ScoreMode.Avg);
Weight weight = s.createNormalizedWeight(q);