public static IndexSearcher wrapUnderlyingReader(final IndexSearcher s, final int edge) 
    throws IOException {

    IndexReader r = s.getIndexReader();

    // we can't put deleted docs before the nested reader, because
    // it will throw off the docIds
    IndexReader[] readers = new IndexReader[] {
      edge < 0 ? r : IndexReader.open(makeEmptyIndex(0), true),
      IndexReader.open(makeEmptyIndex(0), true),
      new MultiReader(new IndexReader[] {
        IndexReader.open(makeEmptyIndex(edge < 0 ? 4 : 0), true),
        IndexReader.open(makeEmptyIndex(0), true),
        0 == edge ? r : IndexReader.open(makeEmptyIndex(0), true)
      }),
      IndexReader.open(makeEmptyIndex(0 < edge ? 0 : 7), true),
      IndexReader.open(makeEmptyIndex(0), true),
      new MultiReader(new IndexReader[] {
        IndexReader.open(makeEmptyIndex(0 < edge ? 0 : 5), true),
        IndexReader.open(makeEmptyIndex(0), true),
        0 < edge ? r : IndexReader.open(makeEmptyIndex(0), true)
      })
    };
    IndexSearcher out = new IndexSearcher(new MultiReader(readers));
    out.setSimilarity(s.getSimilarity());
    return out;
  }