code: @Override
     public Query rewrite(IndexReader reader) throws IOException
     {
        @SuppressWarnings("serial")
        Query stdWildcardQuery = new MultiTermQuery()
        {
           @Override
           protected FilteredTermEnum getEnum(IndexReader reader) throws IOException
           {
              return new WildcardTermEnum(reader, field, propName, pattern, transform);
           }
  
           /** Prints a user-readable version of this query. */
           @Override
           public String toString(String field)
           {
              StringBuilder buffer = new StringBuilder();
              buffer.append(field);
              buffer.append(':');
              buffer.append(ToStringUtils.boost(getBoost()));
              return buffer.toString();
           }
        };
        try
        {
           multiTermQuery = stdWildcardQuery.rewrite(reader);
           return multiTermQuery;
        }
        catch (BooleanQuery.TooManyClauses e)
        {
           // MultiTermQuery not possible
           log.debug("Too many terms to enumerate, using custom WildcardQuery.");
           return this;
        }
     }
docs: Either rewrites this query to a lucene MultiTermQuery or in case of
  a TooManyClauses exception to a custom jackrabbit query implementation
  that uses a BitSet to collect all hits.
  
  @param reader the index reader to use for the search.
  @return the rewritten query.
  @throws IOException if an error occurs while reading from the index.