Search in sources :

Example 1 with AutomatonProvider

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);
}
Also used : Automaton(org.apache.lucene.util.automaton.Automaton) AutomatonProvider(org.apache.lucene.util.automaton.AutomatonProvider)

Aggregations

Automaton (org.apache.lucene.util.automaton.Automaton)1 AutomatonProvider (org.apache.lucene.util.automaton.AutomatonProvider)1