code: @Override
    public MtasSpanQuery rewrite(IndexReader reader) throws IOException {
      Query q = query.rewrite(reader);
      if (q instanceof SpanOrQuery) {
        SpanQuery[] clauses = ((SpanOrQuery) q).getClauses();
        if (clauses.length > MTAS_WILDCARD_EXPAND_BOUNDARY) {
          // forward index solution ?
          throw new IOException("Wildcard expression \""
              + CodecUtil.termValue(term.text()) + "\" expands to "
              + clauses.length + " terms, too many (boundary "
              + MTAS_WILDCARD_EXPAND_BOUNDARY + ")!");
        }
        MtasSpanQuery[] newClauses = new MtasSpanQuery[clauses.length];
        for (int i = 0; i < clauses.length; i++) {
          if (clauses[i] instanceof SpanTermQuery) {
            newClauses[i] = new MtasSpanTermQuery((SpanTermQuery) clauses[i],
                singlePosition);
          } else {
            throw new IOException("no SpanTermQuery after rewrite");
          }
        }
        return new MtasSpanOrQuery(newClauses).rewrite(reader);
      } else {
        throw new IOException("no SpanOrQuery after rewrite");
      }
    }
docs: /*
  (non-Javadoc)
  
  @see
  org.apache.lucene.search.Query#rewrite(org.apache.lucene.index.IndexReader)