code: public Query rewrite(IndexReader reader) throws IOException
     {
        if (transform == TRANSFORM_NONE)
        {
           Query stdRangeQueryImpl =
              new TermRangeQuery(lowerTerm.field(), lowerTerm.text(), upperTerm.text(), inclusive, inclusive);
           try
           {
              stdRangeQuery = stdRangeQueryImpl.rewrite(reader);
              return stdRangeQuery;
           }
           catch (BooleanQuery.TooManyClauses e)
           {
              // failed, use own implementation
              return this;
           }
        }
        else
        {
           // always use our implementation when we need to transform the
           // term enum
           return this;
        }
     }
docs: Tries to rewrite this query into a standard lucene RangeQuery.
  This rewrite might fail with a TooManyClauses exception. If that
  happens, we use our own implementation.
  
  @param reader the index reader.
  @return the rewritten query or this query if rewriting is not possible.
  @throws IOException if an error occurs.