CustomScoreQuery rewritten = (CustomScoreQuery) original.rewrite(s.getIndexReader());
assertTrue("rewritten query should be identical, as TermQuery does not rewrite", original == rewritten);
assertTrue("no hits for query", s.search(rewritten,1).totalHits > 0);
assertEquals(s.search(q,1).totalHits, s.search(rewritten,1).totalHits);
q = new TermRangeQuery(TEXT_FIELD, null, null, true, true); // everything
original = new CustomScoreQuery(q);
rewritten = (CustomScoreQuery) original.rewrite(s.getIndexReader());
assertTrue("rewritten query should not be identical, as TermRangeQuery rewrites", original != rewritten);
assertTrue("no hits for query", s.search(rewritten,1).totalHits > 0);
assertEquals(s.search(q,1).totalHits, s.search(original,1).totalHits);