/** check that the # of hits is the same as from a very simple regexpquery implementation. */ private void assertSame(String regexp) throws IOException { RegexpQuery smart = new RegexpQuery(new Term("field", regexp), RegExp.NONE); DumbRegexpQuery dumb = new DumbRegexpQuery(new Term("field", regexp), RegExp.NONE); // we can't compare the two if automaton rewrites to a simpler enum. // for example: "a\uda07\udcc7?.*?" gets rewritten to a simpler query: // a\uda07* prefixquery. Prefixquery then does the "wrong" thing, which // isn't really wrong as the query was undefined to begin with... but not // automatically comparable. if (!(smart.getTermsEnum(searcher.getIndexReader()) instanceof AutomatonTermsEnum)) return; TopDocs smartDocs = searcher.search(smart, 25); TopDocs dumbDocs = searcher.search(dumb, 25); CheckHits.checkEqual(smart, smartDocs.scoreDocs, dumbDocs.scoreDocs); }