}
/** test a fuzzy query */
public void testFuzzy() throws Exception {
Query regular = new TermQuery(new Term("field", "foobar"));
Query expected = new FuzzyQuery(new Term("field", "foobar"), 2);
assertEquals(expected, parse("foobar~2"));
assertEquals(regular, parse("foobar~"));
assertEquals(regular, parse("foobar~a"));
assertEquals(regular, parse("foobar~1a"));
BooleanQuery bool = new BooleanQuery();
FuzzyQuery fuzzy = new FuzzyQuery(new Term("field", "foo"), LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE);
bool.add(fuzzy, Occur.MUST);
bool.add(new TermQuery(new Term("field", "bar")), Occur.MUST);
assertEquals(bool, parse("foo~" + LevenshteinAutomata.MAXIMUM_SUPPORTED_DISTANCE + 1 + " bar"));
}