public void testLeadingWildcardType() throws Exception { QueryParser qp = getParser(null); qp.setAllowLeadingWildcard(true); assertEquals(WildcardQuery.class, qp.parse("t*erm*").getClass()); assertEquals(WildcardQuery.class, qp.parse("?term*").getClass()); assertEquals(WildcardQuery.class, qp.parse("*term*").getClass()); }
public void assertWildcardQueryEquals( String query, boolean lowercase, String result, boolean allowLeadingWildcard) throws Exception { QueryParser qp = getParser(null); qp.setLowercaseExpandedTerms(lowercase); qp.setAllowLeadingWildcard(allowLeadingWildcard); Query q = qp.parse(query); String s = q.toString("field"); if (!s.equals(result)) { fail("WildcardQuery /" + query + "/ yielded /" + s + "/, expecting /" + result + "/"); } }