code: @Override
    public MtasSpanQuery rewrite(IndexReader reader) throws IOException {
      MtasSpanQuery newBigQuery = bigQuery.rewrite(reader);
      MtasSpanQuery newSmallQuery = smallQuery.rewrite(reader);
      if (newBigQuery == null || newBigQuery instanceof MtasSpanMatchNoneQuery
          || newSmallQuery == null
          || newSmallQuery instanceof MtasSpanMatchNoneQuery) {
        return new MtasSpanMatchNoneQuery(field);
      }
      if (!newBigQuery.equals(bigQuery) || !newSmallQuery.equals(smallQuery)) {
        return new MtasSpanContainingQuery(newBigQuery, newSmallQuery)
            .rewrite(reader);
      } else if (newBigQuery.equals(newSmallQuery)) {
        return newBigQuery;
      } else if (baseQuery == null) {
        return new MtasSpanMatchNoneQuery(field);
      } else {
        baseQuery = (SpanContainingQuery) baseQuery.rewrite(reader);
        return super.rewrite(reader);
      }
    }
docs: /*
  (non-Javadoc)
  
  @see mtas.search.spans.util.MtasSpanQuery#rewrite(org.apache.lucene.index.
  IndexReader)