List of usage examples for org.apache.lucene.util.automaton Operations concatenate
static public Automaton concatenate(List<Automaton> l)
From source file:org.codelibs.elasticsearch.common.regex.Regex.java
License:Apache License
/** Return an {Automaton} that matches the given pattern. */ public static Automaton simpleMatchToAutomaton(String pattern) { List<Automaton> automata = new ArrayList<>(); int previous = 0; for (int i = pattern.indexOf('*'); i != -1; i = pattern.indexOf('*', i + 1)) { automata.add(Automata.makeString(pattern.substring(previous, i))); automata.add(Automata.makeAnyString()); previous = i + 1;/* w w w .ja va2 s .c om*/ } automata.add(Automata.makeString(pattern.substring(previous))); return Operations.concatenate(automata); }
From source file:org.codelibs.elasticsearch.common.xcontent.support.XContentMapValues.java
License:Apache License
/** Make matches on objects also match dots in field names. * For instance, if the original simple regex is `foo`, this will translate * it into `foo` OR `foo.*`. *//*w ww. jav a 2 s .c o m*/ private static Automaton makeMatchDotsInFieldNames(Automaton automaton) { return Operations.union(automaton, Operations.concatenate(Arrays.asList(automaton, Automata.makeChar('.'), Automata.makeAnyString()))); }