use of org.apache.lucene.util.automaton.AutomatonProvider in project lucene-solr by apache.
the class TestRegexpQuery method testCustomProvider.
public void testCustomProvider() throws IOException {
AutomatonProvider myProvider = new AutomatonProvider() {
// automaton that matches quick or brown
private Automaton quickBrownAutomaton = Operations.union(Arrays.asList(Automata.makeString("quick"), Automata.makeString("brown"), Automata.makeString("bob")));
@Override
public Automaton getAutomaton(String name) {
if (name.equals("quickBrown"))
return quickBrownAutomaton;
else
return null;
}
};
RegexpQuery query = new RegexpQuery(newTerm("<quickBrown>"), RegExp.ALL, myProvider, DEFAULT_MAX_DETERMINIZED_STATES);
assertEquals(1, searcher.search(query, 5).totalHits);
}
Aggregations