Apache Lucene open-source search software
LUCENE-10414: Add fn:fuzzyTerm interval function to flexible query parser (#668)
Dawid Weissf6cebac33379
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txtindex 8e4b743c047..e9c2bd32958 100644--- a/lucene/CHANGES.txt+++ b/lucene/CHANGES.txt@@ -144,6 +144,9 @@ New Features* LUCENE-10403: Add ArrayUtil#grow(T[]). (Greg Miller)+* LUCENE-10414: Add fn:fuzzyTerm interval function to flexible query parser (Dawid Weiss,+ Alan Woodward)+Improvements---------------------diff --git a/lucene/core/src/java/org/apache/lucene/search/FuzzyQuery.java b/lucene/core/src/java/org/apache/lucene/search/FuzzyQuery.javaindex 260ce2b14b7..8e31ba41cbe 100644--- a/lucene/core/src/java/org/apache/lucene/search/FuzzyQuery.java+++ b/lucene/core/src/java/org/apache/lucene/search/FuzzyQuery.java@@ -141,8 +141,27 @@ public class FuzzyQuery extends MultiTermQuery {/** Returns the compiled automata used to match terms */public CompiledAutomaton getAutomata() {+ return getFuzzyAutomaton(term.text(), maxEdits, prefixLength, transpositions);+ }++ /**+ * Returns the {@link CompiledAutomaton} internally used by {@link FuzzyQuery} to match terms.+ * This is a very low-level method and may no longer exist in case the implementation of+ * fuzzy-matching changes in the future.+ *+ * @lucene.internal+ * @param term the term to search for+ * @param maxEdits must be {@code >= 0} and {@code <=} {@link+ * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}.+ * @param prefixLength length of common (non-fuzzy) prefix+ * @param transpositions true if transpositions should be treated as a primitive edit operation.+ * If this is false, comparisons will implement the classic Levenshtein algorithm.+ * @return A {@link CompiledAutomaton} that matches terms that satisfy input parameters.+ */+ public static CompiledAutomaton getFuzzyAutomaton(+ String term, int maxEdits, int prefixLength, boolean transpositions) {FuzzyAutomatonBuilder builder =- new FuzzyAutomatonBuilder(term.text(), maxEdits, prefixLength, transpositions);+ new FuzzyAutomatonBuilder(term, maxEdits, prefixLength, transpositions);return builder.buildMaxEditAutomaton();}diff --git a/lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchHighlighter.java b/lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchHighlighter.javaindex c6a6261b8b3..5babc1c134b 100644--- a/lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchHighlighter.java+++ b/lucene/highlighter/src/test/org/apache/lucene/search/matchhighlight/TestMatchHighlighter.java@@ -332,252 +332,13 @@ public class TestMatchHighlighter extends LuceneTestCase {}};- String field = FLD_TEXT2;- new IndexBuilder(this::toField)- // Just one document and multiple interval queries.- .doc(field, "The quick brown fox jumps over the lazy dog")- .build(- analyzer,- reader -> {- IndexSearcher searcher = new IndexSearcher(reader);- Sort sortOrder = Sort.INDEXORDER; // So that results are consistently ordered.-- MatchHighlighter highlighter =- new MatchHighlighter(searcher, analyzer)- .appendFieldHighlighter(- FieldValueHighlighters.highlighted(- 80 * 3, 1, new PassageFormatter("...", ">", "<"), fld -> true))- .appendFieldHighlighter(FieldValueHighlighters.skipRemaining());-- StandardQueryParser qp = new StandardQueryParser(analyzer);+ // Rerun the same test on fields with offsets and without offsets.+ for (String field : List.of(FLD_TEXT1, FLD_TEXT2)) {+ String inputDocument = "The quick brown fox jumps over the lazy dog";- // Run all pairs of query-expected highlight.- List<String> errors = new ArrayList<>();- for (var queryHighlightPair :- new String[][] {- {- "fn:ordered(brown dog)",- "0. %s: The quick >brown fox jumps over the lazy dog<"- },- {- "fn:within(fn:or(lazy quick) 1 fn:or(dog fox))",- "0. %s: The quick brown fox jumps over the >lazy< dog"- },- {- "fn:containedBy(fox fn:ordered(brown fox dog))",- "0. %s: The quick brown >fox< jumps over the lazy dog"- },- {- "fn:atLeast(2 fn:unordered(furry dog) fn:unordered(brown dog) lazy quick)",- "0. %s: The >quick >brown fox jumps over the lazy<<> dog<"- },- {- "fn:atLeast(2 quick fox \"furry dog\")",- "0. %s: The >quick brown fox< jumps over the lazy dog"- },- {- "fn:maxgaps(0 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",- "0. %s: The quick brown fox jumps over the >lazy dog<"- },- {- "fn:maxgaps(1 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",- "0. %s: The >quick brown fox< jumps over the >lazy dog<"- },- {- "fn:maxwidth(2 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",- "0. %s: The quick brown fox jumps over the >lazy dog<"- },- {- "fn:maxwidth(3 fn:ordered(fn:or(quick lazy) fn:or(fox dog)))",- "0. %s: The >quick brown fox< jumps over the >lazy dog<"- },- {- "fn:or(quick \"fox\")",- "0. %s: The >quick< brown >fox< jumps over the lazy dog"- },- {"fn:or(\"quick fox\")"},- {- "fn:phrase(quick brown fox)",- "0. %s: The >quick brown fox< jumps over the lazy dog"- },- {"fn:wildcard(jump*)", "0. %s: The quick brown fox >jumps< over the lazy dog"},- {"fn:wildcard(br*n)", "0. %s: The quick >brown< fox jumps over the lazy dog"},- {"fn:or(dog fox)", "0. %s: The quick brown >fox< jumps over the lazy >dog<"},- {- "fn:phrase(fn:ordered(quick fox) jumps)",- "0. %s: The >quick brown fox jumps< over the lazy dog"- },- {- "fn:ordered(quick jumps dog)",- "0. %s: The >quick brown fox jumps over the lazy dog<"- },- {- "fn:ordered(quick fn:or(fox dog))",- "0. %s: The >quick brown fox< jumps over the lazy dog"- },- {- "fn:ordered(quick jumps fn:or(fox dog))",- "0. %s: The >quick brown fox jumps over the lazy dog<"- },- {- "fn:unordered(dog jumps quick)",- "0. %s: The >quick brown fox jumps over the lazy dog<"- },- {- "fn:unordered(fn:or(fox dog) quick)",- "0. %s: The >quick brown fox< jumps over the lazy dog"- },- {- "fn:unordered(fn:phrase(brown fox) fn:phrase(fox jumps))",- "0. %s: The quick >brown fox jumps< over the lazy dog"- },- {"fn:ordered(fn:phrase(brown fox) fn:phrase(fox jumps))"},- {"fn:unorderedNoOverlaps(fn:phrase(brown fox) fn:phrase(fox jumps))"},- {- "fn:before(fn:or(brown lazy) fox)",- "0. %s: The quick >brown< fox jumps over the lazy dog"- },- {- "fn:before(fn:or(brown lazy) fn:or(dog fox))",- "0. %s: The quick >brown< fox jumps over the >lazy< dog"- },- {- "fn:after(fn:or(brown lazy) fox)",- "0. %s: The quick brown fox jumps over the >lazy< dog"- },- {- "fn:after(fn:or(brown lazy) fn:or(dog fox))",- "0. %s: The quick brown fox jumps over the >lazy< dog"- },- {"fn:extend(fox 1 2)", "0. %s: The quick >brown fox jumps over< the lazy dog"},- {- "fn:extend(fn:or(dog fox) 2 0)",- "0. %s: The >quick brown fox< jumps over >the lazy dog<"- },- {- "fn:within(fn:or(fox dog) 1 fn:or(quick lazy))",- "0. %s: The quick brown fox jumps over the lazy >dog<"- },- {- "fn:within(fn:or(fox dog) 2 fn:or(quick lazy))",- "0. %s: The quick brown >fox< jumps over the lazy >dog<"- },- {- "fn:notWithin(fn:or(fox dog) 1 fn:or(quick lazy))",- "0. %s: The quick brown >fox< jumps over the lazy dog"- },- {- "fn:containedBy(fn:or(fox dog) fn:extend(lazy 3 3))",- "0. %s: The quick brown fox jumps over the lazy >dog<"- },- {- "fn:containedBy(fn:or(fox dog) fn:ordered(quick lazy))",- "0. %s: The quick brown >fox< jumps over the lazy dog"- },- {- "fn:notContainedBy(fn:or(fox dog) fn:extend(lazy 3 3))",- "0. %s: The quick brown >fox< jumps over the lazy dog"- },- {- "fn:notContainedBy(fn:or(fox dog) fn:ordered(quick lazy))",- "0. %s: The quick brown fox jumps over the lazy >dog<"- },- {- "fn:containing(fn:extend(fn:or(lazy brown) 1 1) fn:or(fox dog))",- "0. %s: The >quick brown fox< jumps over >the lazy dog<"- },- {- "fn:containing(fn:atLeast(2 quick fox dog) jumps)",- "0. %s: The quick brown >fox jumps over the lazy dog<"- },- {- "fn:notContaining(fn:ordered(fn:or(the The) fn:or(fox dog)) brown)",- "0. %s: The quick brown fox jumps over >the lazy dog<"- },- {- "fn:notContaining(fn:extend(fn:or(fox dog) 1 0) fn:or(brown yellow))",- "0. %s: The quick brown fox jumps over the >lazy dog<"- },- {- "fn:overlapping(fn:phrase(brown fox) fn:phrase(fox jumps))",- "0. %s: The quick >brown fox< jumps over the lazy dog"- },- {- "fn:overlapping(fn:or(fox dog) fn:extend(lazy 2 2))",- "0. %s: The quick brown fox jumps over the lazy >dog<"- },- {- "fn:nonOverlapping(fn:phrase(brown fox) fn:phrase(lazy dog))",- "0. %s: The quick >brown fox< jumps over the lazy dog"- },- {- "fn:nonOverlapping(fn:or(fox dog) fn:extend(lazy 2 2))",- "0. %s: The quick brown >fox< jumps over the lazy dog"- },- }) {- assert queryHighlightPair.length >= 1;- String queryString = queryHighlightPair[0];- var query = qp.parse(queryString, field);- var expected =- Arrays.stream(queryHighlightPair)- .skip(1)- .map(v -> String.format(Locale.ROOT, v, field))- .toArray(String[]::new);-- try {- assertHighlights(- toDocList(- highlighter.highlight(searcher.search(query, 10, sortOrder), query)),- expected);- } catch (AssertionError e) {- errors.add("MISMATCH: query: " + queryString + "\n" + e.getMessage());- }- }- if (errors.size() > 0) {- throw new AssertionError(String.join("\n\n", errors));- }- });- }-- /**- * Almost the same as the one above, make sure the fields indexed with offsets are also- * highlighted correctly- */- @Test- public void testIntervalFunctionsWithOffsetField() throws Exception {- Analyzer analyzer =- new Analyzer() {- @Override- protected TokenStreamComponents createComponents(String fieldName) {- Tokenizer tokenizer = new StandardTokenizer();- TokenStream ts = tokenizer;- ts = new LowerCaseFilter(ts);- return new TokenStreamComponents(tokenizer, ts);- }- };-- String field = FLD_TEXT1;- new IndexBuilder(this::toField)- // Just one document and multiple interval queries.- .doc(field, "The quick brown fox jumps over the lazy dog")- .build(- analyzer,- reader -> {- IndexSearcher searcher = new IndexSearcher(reader);- Sort sortOrder = Sort.INDEXORDER; // So that results are consistently ordered.-- MatchHighlighter highlighter =- new MatchHighlighter(searcher, analyzer)- .appendFieldHighlighter(- FieldValueHighlighters.highlighted(- 80 * 3, 1, new PassageFormatter("...", ">", "<"), fld -> true))- .appendFieldHighlighter(FieldValueHighlighters.skipRemaining());-- StandardQueryParser qp = new StandardQueryParser(analyzer);-- // Run all pairs of query-expected highlight.- List<String> errors = new ArrayList<>();- for (var queryHighlightPair :+ List<String[]> queryResultPairs =+ new ArrayList<>(+ Arrays.asList(new String[][] {{"fn:ordered(brown dog)",@@ -622,6 +383,7 @@ public class TestMatchHighlighter extends LuceneTestCase {},{"fn:wildcard(jump*)", "0. %s: The quick brown fox >jumps< over the lazy dog"},{"fn:wildcard(br*n)", "0. %s: The quick >brown< fox jumps over the lazy dog"},+ {"fn:fuzzyTerm(fxo)", "0. %s: The quick brown >fox< jumps over the lazy dog"},{"fn:or(dog fox)", "0. %s: The quick brown >fox< jumps over the lazy >dog<"},{"fn:phrase(fn:ordered(quick fox) jumps)",@@ -717,55 +479,83 @@ public class TestMatchHighlighter extends LuceneTestCase {"fn:atLeast(2 fn:unordered(furry dog) fn:unordered(brown dog) lazy quick)","0. %s: The >quick >brown fox jumps over the lazy<<> dog<"},- /*- The test cases below do not work for fields enabled with offset yet:- mainly "extend"- TODO: LUCENE-10229: fix these remaining cases.+ }));++ // TODO: LUCENE-10229: The test cases below do not work for fields enabled with offset yet:+ // mainly "extend".+ if (field.equals(FLD_TEXT2)) {+ queryResultPairs.addAll(+ Arrays.asList(+ new String[][] {+ {"fn:extend(fox 1 2)", "0. %s: The quick >brown fox jumps over< the lazy dog"},+ {+ "fn:extend(fn:or(dog fox) 2 0)",+ "0. %s: The >quick brown fox< jumps over >the lazy dog<"+ },+ {+ "fn:containedBy(fn:or(fox dog) fn:extend(lazy 3 3))",+ "0. %s: The quick brown fox jumps over the lazy >dog<"+ },+ {+ "fn:notContainedBy(fn:or(fox dog) fn:extend(lazy 3 3))",+ "0. %s: The quick brown >fox< jumps over the lazy dog"+ },+ {+ "fn:containing(fn:extend(fn:or(lazy brown) 1 1) fn:or(fox dog))",+ "0. %s: The >quick brown fox< jumps over >the lazy dog<"+ },+ {+ "fn:notContaining(fn:extend(fn:or(fox dog) 1 0) fn:or(brown yellow))",+ "0. %s: The quick brown fox jumps over the >lazy dog<"+ }+ }));+ }- {"fn:extend(fox 1 2)", "0. %s: The quick >brown fox jumps over< the lazy dog"},- {- "fn:extend(fn:or(dog fox) 2 0)",- "0. %s: The >quick brown fox< jumps over >the lazy dog<"- },- {- "fn:containedBy(fn:or(fox dog) fn:extend(lazy 3 3))",- "0. %s: The quick brown fox jumps over the lazy >dog<"- },- {- "fn:notContainedBy(fn:or(fox dog) fn:extend(lazy 3 3))",- "0. %s: The quick brown >fox< jumps over the lazy dog"- },- {- "fn:containing(fn:extend(fn:or(lazy brown) 1 1) fn:or(fox dog))",- "0. %s: The >quick brown fox< jumps over >the lazy dog<"- },- {- "fn:notContaining(fn:extend(fn:or(fox dog) 1 0) fn:or(brown yellow))",- "0. %s: The quick brown fox jumps over the >lazy dog<"- } */- }) {- assert queryHighlightPair.length >= 1;- String queryString = queryHighlightPair[0];- var query = qp.parse(queryString, field);- var expected =- Arrays.stream(queryHighlightPair)- .skip(1)- .map(v -> String.format(Locale.ROOT, v, field))- .toArray(String[]::new);-- try {- assertHighlights(- toDocList(- highlighter.highlight(searcher.search(query, 10, sortOrder), query)),- expected);- } catch (AssertionError e) {- errors.add("MISMATCH: query: " + queryString + "\n" + e.getMessage());+ // Verify assertions.+ new IndexBuilder(this::toField)+ // Just one document and multiple interval queries to check.+ .doc(field, inputDocument)+ .build(+ analyzer,+ reader -> {+ IndexSearcher searcher = new IndexSearcher(reader);+ Sort sortOrder = Sort.INDEXORDER; // So that results are consistently ordered.++ MatchHighlighter highlighter =+ new MatchHighlighter(searcher, analyzer)+ .appendFieldHighlighter(+ FieldValueHighlighters.highlighted(+ 80 * 3, 1, new PassageFormatter("...", ">", "<"), fld -> true))+ .appendFieldHighlighter(FieldValueHighlighters.skipRemaining());++ StandardQueryParser qp = new StandardQueryParser(analyzer);++ // Run all pairs of query-expected highlight.+ List<String> errors = new ArrayList<>();+ for (var queryHighlightPair : queryResultPairs) {+ assert queryHighlightPair.length >= 1;+ String queryString = queryHighlightPair[0];+ var query = qp.parse(queryString, field);+ var expected =+ Arrays.stream(queryHighlightPair)+ .skip(1)+ .map(v -> String.format(Locale.ROOT, v, field))+ .toArray(String[]::new);++ try {+ assertHighlights(+ toDocList(+ highlighter.highlight(searcher.search(query, 10, sortOrder), query)),+ expected);+ } catch (AssertionError e) {+ errors.add("MISMATCH: query: " + queryString + "\n" + e.getMessage());+ }}- }- if (errors.size() > 0) {- throw new AssertionError(String.join("\n\n", errors));- }- });+ if (errors.size() > 0) {+ throw new AssertionError(String.join("\n\n", errors));+ }+ });+ }}@Testdiff --git a/lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java b/lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.javaindex 0e6e967197a..ae494b90a95 100644--- a/lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java+++ b/lucene/queries/src/java/org/apache/lucene/queries/intervals/Intervals.java@@ -25,10 +25,12 @@ import org.apache.lucene.analysis.Analyzer;import org.apache.lucene.analysis.CachingTokenFilter;import org.apache.lucene.analysis.TokenStream;import org.apache.lucene.index.Term;+import org.apache.lucene.search.FuzzyQuery;import org.apache.lucene.search.PrefixQuery;import org.apache.lucene.search.WildcardQuery;import org.apache.lucene.util.BytesRef;import org.apache.lucene.util.automaton.CompiledAutomaton;+import org.apache.lucene.util.automaton.LevenshteinAutomata;import org.apache.lucene.util.automaton.Operations;/**@@ -48,6 +50,14 @@ import org.apache.lucene.util.automaton.Operations;* {@link #or(boolean, IntervalsSource...)} factory method to prevent rewriting.*/public final class Intervals {+ /**+ * The default number of expansions in:+ *+ * <ul>+ * <li>{@link #multiterm(CompiledAutomaton, String)}+ * </ul>+ */+ public static final int DEFAULT_MAX_EXPANSIONS = 128;private Intervals() {}@@ -140,18 +150,19 @@ public final class Intervals {/*** Return an {@link IntervalsSource} over the disjunction of all terms that begin with a prefix*- * @throws IllegalStateException if the prefix expands to more than 128 terms+ * @throws IllegalStateException if the prefix expands to more than {@link+ * #DEFAULT_MAX_EXPANSIONS} terms*/public static IntervalsSource prefix(BytesRef prefix) {- return prefix(prefix, 128);+ return prefix(prefix, DEFAULT_MAX_EXPANSIONS);}/*** Expert: Return an {@link IntervalsSource} over the disjunction of all terms that begin with a* prefix*- * <p>WARNING: Setting {@code maxExpansions} to higher than the default value of 128 can be both- * slow and memory-intensive+ * <p>WARNING: Setting {@code maxExpansions} to higher than the default value of {@link+ * #DEFAULT_MAX_EXPANSIONS} can be both slow and memory-intensive** @param prefix the prefix to expand* @param maxExpansions the maximum number of terms to expand to@@ -165,19 +176,20 @@ public final class Intervals {/*** Return an {@link IntervalsSource} over the disjunction of all terms that match a wildcard glob*- * @throws IllegalStateException if the wildcard glob expands to more than 128 terms+ * @throws IllegalStateException if the wildcard glob expands to more than {@link+ * #DEFAULT_MAX_EXPANSIONS} terms* @see WildcardQuery for glob format*/public static IntervalsSource wildcard(BytesRef wildcard) {- return wildcard(wildcard, 128);+ return wildcard(wildcard, DEFAULT_MAX_EXPANSIONS);}/*** Expert: Return an {@link IntervalsSource} over the disjunction of all terms that match a* wildcard glob*- * <p>WARNING: Setting {@code maxExpansions} to higher than the default value of 128 can be both- * slow and memory-intensive+ * <p>WARNING: Setting {@code maxExpansions} to higher than the default value of {@link+ * #DEFAULT_MAX_EXPANSIONS} can be both slow and memory-intensive** @param wildcard the glob to expand* @param maxExpansions the maximum number of terms to expand to@@ -193,24 +205,70 @@ public final class Intervals {return new MultiTermIntervalsSource(ca, maxExpansions, wildcard.utf8ToString());}+ /**+ * A fuzzy term {@link IntervalsSource} matches the disjunction of intervals of terms that are+ * within the specified {@code maxEdits} from the provided term.+ *+ * @see #fuzzyTerm(String, int, int, boolean, int)+ * @param term the term to search for+ * @param maxEdits must be {@code >= 0} and {@code <=} {@link+ * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}, use {@link FuzzyQuery#defaultMaxEdits} for+ * the default, if needed.+ */+ public static IntervalsSource fuzzyTerm(String term, int maxEdits) {+ return fuzzyTerm(+ term,+ maxEdits,+ FuzzyQuery.defaultPrefixLength,+ FuzzyQuery.defaultTranspositions,+ DEFAULT_MAX_EXPANSIONS);+ }++ /**+ * A fuzzy term {@link IntervalsSource} matches the disjunction of intervals of terms that are+ * within the specified {@code maxEdits} from the provided term.+ *+ * <p>The implementation is delegated to a {@link #multiterm(CompiledAutomaton, int, String)}+ * interval source, with an automaton sourced from {@link org.apache.lucene.search.FuzzyQuery}.+ *+ * @param term the term to search for+ * @param maxEdits must be {@code >= 0} and {@code <=} {@link+ * LevenshteinAutomata#MAXIMUM_SUPPORTED_DISTANCE}, use {@link FuzzyQuery#defaultMaxEdits} for+ * the default, if needed.+ * @param prefixLength length of common (non-fuzzy) prefix+ * @param maxExpansions the maximum number of terms to match. Setting {@code maxExpansions} to+ * higher than the default value of {@link #DEFAULT_MAX_EXPANSIONS} can be both slow and+ * memory-intensive+ * @param transpositions true if transpositions should be treated as a primitive edit operation.+ * If this is false, comparisons will implement the classic Levenshtein algorithm.+ */+ public static IntervalsSource fuzzyTerm(+ String term, int maxEdits, int prefixLength, boolean transpositions, int maxExpansions) {+ return Intervals.multiterm(+ FuzzyQuery.getFuzzyAutomaton(term, maxEdits, prefixLength, transpositions),+ maxExpansions,+ term + "~" + maxEdits);+ }+/*** Expert: Return an {@link IntervalsSource} over the disjunction of all terms that are accepted* by the given automaton** @param ca an automaton accepting matching terms* @param pattern string representation of the given automaton, mostly used in exception messages- * @throws IllegalStateException if the automaton accepts more than 128 terms+ * @throws IllegalStateException if the automaton accepts more than {@link+ * #DEFAULT_MAX_EXPANSIONS} terms*/public static IntervalsSource multiterm(CompiledAutomaton ca, String pattern) {- return multiterm(ca, 128, pattern);+ return multiterm(ca, DEFAULT_MAX_EXPANSIONS, pattern);}/*** Expert: Return an {@link IntervalsSource} over the disjunction of all terms that are accepted* by the given automaton*- * <p>WARNING: Setting {@code maxExpansions} to higher than the default value of 128 can be both- * slow and memory-intensive+ * <p>WARNING: Setting {@code maxExpansions} to higher than the default value of {@link+ * #DEFAULT_MAX_EXPANSIONS} can be both slow and memory-intensive** @param ca an automaton accepting matching terms* @param maxExpansions the maximum number of terms to expand todiff --git a/lucene/queries/src/test/org/apache/lucene/queries/intervals/TestIntervals.java b/lucene/queries/src/test/org/apache/lucene/queries/intervals/TestIntervals.javaindex 78403150389..8aca8738d39 100644--- a/lucene/queries/src/test/org/apache/lucene/queries/intervals/TestIntervals.java+++ b/lucene/queries/src/test/org/apache/lucene/queries/intervals/TestIntervals.java@@ -40,6 +40,7 @@ import org.apache.lucene.index.NumericDocValues;import org.apache.lucene.index.ReaderUtil;import org.apache.lucene.index.Term;import org.apache.lucene.search.BooleanClause;+import org.apache.lucene.search.FuzzyQuery;import org.apache.lucene.search.IndexSearcher;import org.apache.lucene.search.MatchesIterator;import org.apache.lucene.search.Query;@@ -1003,8 +1004,48 @@ public class TestIntervals extends LuceneTestCase {checkVisits(Intervals.wildcard(new BytesRef("p??")), 1);}- public void testWrappedFilters() throws IOException {+ public void testFuzzyTerm() throws IOException {+ IntervalsSource source = Intervals.fuzzyTerm("kot", 1); // matches 'pot'+ checkIntervals(+ source,+ "field1",+ 4,+ new int[][] {+ {},+ {2, 2, 10, 10, 17, 17, 27, 27},+ {5, 5, 10, 10, 21, 21},+ {3, 3},+ {2, 2, 10, 10, 17, 17},+ {}+ });+ MatchesIterator mi = getMatches(source, 4, "field1");+ assertNotNull(mi);+ assertMatch(mi, 2, 2, 15, 18);+ assertMatch(mi, 10, 10, 63, 66);+ assertMatch(mi, 17, 17, 97, 100);+ // Check limits.+ IllegalStateException e =+ expectThrows(+ IllegalStateException.class,+ () -> {+ IntervalsSource s =+ Intervals.fuzzyTerm(+ "kot",+ 1,+ FuzzyQuery.defaultPrefixLength,+ FuzzyQuery.defaultTranspositions,+ 1);+ for (LeafReaderContext ctx : searcher.getIndexReader().leaves()) {+ s.intervals("field1", ctx);+ }+ });+ assertEquals("Automaton [kot~1] expanded to too many terms (limit 1)", e.getMessage());++ checkVisits(Intervals.fuzzyTerm("kot", FuzzyQuery.defaultMaxEdits), 1);+ }++ public void testWrappedFilters() throws IOException {IntervalsSource source =Intervals.or(Intervals.term("nine"),diff --git a/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json b/lucene/queryparser/src/generated/checksums/javaccParserFlexible.jsonindex 3533be4eca3..b6802f928b5 100644--- a/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json+++ b/lucene/queryparser/src/generated/checksums/javaccParserFlexible.json@@ -1,9 +1,9 @@{"lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/ParseException.java": "3d5f272a6d56b3f4962b252267ce2662e734414e",- "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java": "fd1fcc78bf1025fe6fe54ab6f9ae2f53cce33364",- "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj": "eb0d1c55d029982ab8ea433cf9ef1088ba6ea3de",- "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.java": "d3c5d87c46635dbb6dc03bbdc0fb662b47ec318d",- "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java": "d8e12b467779c1740ea2b672c10806ac25e0184e",+ "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java": "6a9e8f350d6726d2f1b86f1cd6d5e747dda7ca6c",+ "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj": "77ebf56c78a8614a82532ca6bdf69378afd44b8f",+ "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.java": "4ad426d4f4b7577f4af4e9057de32c65c83b1812",+ "lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java": "88eae6e992c65b3050949054b0f636d5e2654cc8","lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/Token.java": "f4cb9d01587279dba30e549ce4867e4381bbd9d7","lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/TokenMgrError.java": "cdfa99af5fcf6b1e50691a1c1370ba60bf0d2d2d"}\ No newline at end of filediff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/AnalyzedText.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/AnalyzedText.javaindex 4cba173983c..1aee75c42f7 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/AnalyzedText.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/AnalyzedText.java@@ -50,7 +50,7 @@ public class AnalyzedText extends IntervalFunction {}}- private boolean requiresQuotes(String term) {+ static boolean requiresQuotes(String term) {return Pattern.compile("[\\s]").matcher(term).find();}}diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/FuzzyTerm.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/FuzzyTerm.javanew file mode 100644index 00000000000..8ad79b2fc44--- /dev/null+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/FuzzyTerm.java@@ -0,0 +1,61 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */+package org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn;++import java.util.Locale;+import org.apache.lucene.analysis.Analyzer;+import org.apache.lucene.queries.intervals.Intervals;+import org.apache.lucene.queries.intervals.IntervalsSource;+import org.apache.lucene.search.FuzzyQuery;++/**+ * An interval function equivalent to {@link FuzzyQuery}. A fuzzy term expands to a disjunction of+ * intervals of terms that are within the specified {@code maxEdits} from the provided term. A limit+ * of {@code maxExpansions} prevents the internal implementation from blowing up on too many+ * potential candidate terms.+ */+public class FuzzyTerm extends IntervalFunction {+ private final String term;+ private final int maxEdits;+ private final Integer maxExpansions;++ public FuzzyTerm(String term, Integer maxEdits, Integer maxExpansions) {+ this.term = term;+ this.maxEdits = maxEdits == null ? FuzzyQuery.defaultMaxEdits : maxEdits;+ this.maxExpansions = maxExpansions == null ? Intervals.DEFAULT_MAX_EXPANSIONS : maxExpansions;+ }++ @Override+ public IntervalsSource toIntervalSource(String field, Analyzer analyzer) {+ return Intervals.fuzzyTerm(+ term,+ maxEdits,+ FuzzyQuery.defaultPrefixLength,+ FuzzyQuery.defaultTranspositions,+ maxExpansions);+ }++ @Override+ public String toString() {+ return String.format(+ Locale.ROOT,+ "fn:fuzzyTerm(%s %d%s)",+ AnalyzedText.requiresQuotes(term) ? '"' + term + '"' : term,+ maxEdits,+ maxExpansions);+ }+}diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/Wildcard.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/Wildcard.javaindex ce4bb072adf..fce653af63e 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/Wildcard.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/nodes/intervalfn/Wildcard.java@@ -25,18 +25,28 @@ import org.apache.lucene.util.BytesRef;/** Node that represents {@link Intervals#wildcard(BytesRef)}. */public class Wildcard extends IntervalFunction {private final String wildcard;+ private final int maxExpansions;- public Wildcard(String wildcard) {+ public Wildcard(String wildcard, int maxExpansions) {this.wildcard = wildcard;+ this.maxExpansions = maxExpansions;}@Overridepublic IntervalsSource toIntervalSource(String field, Analyzer analyzer) {- return Intervals.wildcard(new BytesRef(wildcard));+ if (maxExpansions == 0) {+ return Intervals.wildcard(new BytesRef(wildcard));+ } else {+ return Intervals.wildcard(new BytesRef(wildcard), maxExpansions);+ }}@Overridepublic String toString() {- return String.format(Locale.ROOT, "fn:wildcard(%s)", wildcard);+ return String.format(+ Locale.ROOT,+ "fn:wildcard(%s%s)",+ wildcard,+ maxExpansions == 0 ? "" : " maxExpansions:" + maxExpansions);}}diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.javaindex f9575cb374c..9bf2efb180e 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.java@@ -47,6 +47,7 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.Before;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.ContainedBy;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.Containing;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.Extend;+import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.FuzzyTerm;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.IntervalFunction;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.MaxGaps;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.MaxWidth;@@ -339,8 +340,8 @@ if (modifier != ModifierQueryNode.Modifier.MOD_NONE) {;}switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {- case 55:{- jj_consume_token(55);+ case 56:{+ jj_consume_token(56);minShouldMatch = jj_consume_token(NUMBER);break;}@@ -425,6 +426,9 @@ if (minShouldMatch != null) {source = IntervalExtend();{if ("" != null) return source;}} else if (jj_2_24(2)) {+ source = IntervalFuzzyTerm();+{if ("" != null) return source;}+ } else if (jj_2_25(2)) {source = IntervalText();{if ("" != null) return source;}} else {@@ -740,6 +744,7 @@ sources.add(source);}final private IntervalFunction IntervalWildcard() throws ParseException {String wildcard;+ Token maxExpansions = null;jj_consume_token(FN_PREFIX);jj_consume_token(WILDCARD);jj_consume_token(LPAREN);@@ -773,8 +778,70 @@ wildcard = token.image.substring(1, token.image.length() - 1);jj_consume_token(-1);throw new ParseException();}+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {+ case NUMBER:{+ maxExpansions = jj_consume_token(NUMBER);+ break;+ }+ default:+ jj_la1[18] = jj_gen;+ ;+ }+ jj_consume_token(RPAREN);+{if ("" != null) return new Wildcard(wildcard, maxExpansions == null ? 0 : parseInt(maxExpansions));}+ throw new Error("Missing return statement in function");+}++ final private IntervalFunction IntervalFuzzyTerm() throws ParseException {String term;+ Token maxEdits = null;+ Token maxExpansions = null;+ jj_consume_token(FN_PREFIX);+ jj_consume_token(FUZZYTERM);+ jj_consume_token(LPAREN);+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {+ case NUMBER:+ case TERM:{+ switch ((jj_ntk==-1)?jj_ntk_f():jj_ntk) {+ case TERM:{+ jj_consume_token(TERM);+ break;+ }+ case NUMBER:{+ jj_consume_token(NUMBER);+ break;+ }+ default:+ jj_la1[19] = jj_gen;+ jj_consume_token(-1);+ throw new ParseException();+ }+term = token.image;+ break;+ }+ case QUOTED:{+ jj_consume_token(QUOTED);+term = token.image.substring(1, token.image.length() - 1);+ break;+ }+ default:+ jj_la1[20] = jj_gen;+ jj_consume_token(-1);+ throw new ParseException();+ }+ if (jj_2_26(2)) {+ maxEdits = jj_consume_token(NUMBER);+ } else {+ ;+ }+ if (jj_2_27(2)) {+ maxExpansions = jj_consume_token(NUMBER);+ } else {+ ;+ }jj_consume_token(RPAREN);-{if ("" != null) return new Wildcard(wildcard);}+{if ("" != null) return new FuzzyTerm(term,+ maxEdits == null ? null : parseInt(maxEdits),+ maxExpansions == null ? null : parseInt(maxExpansions));}throw new Error("Missing return statement in function");}@@ -797,7 +864,7 @@ wildcard = token.image.substring(1, token.image.length() - 1);break;}default:- jj_la1[18] = jj_gen;+ jj_la1[21] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -805,7 +872,7 @@ wildcard = token.image.substring(1, token.image.length() - 1);break;}default:- jj_la1[19] = jj_gen;+ jj_la1[22] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -821,7 +888,7 @@ wildcard = token.image.substring(1, token.image.length() - 1);final private QueryNode FuzzyOp(CharSequence field, Token term, QueryNode node) throws ParseException {Token similarity = null;jj_consume_token(TILDE);- if (jj_2_25(2)) {+ if (jj_2_28(2)) {similarity = jj_consume_token(NUMBER);} else {;@@ -861,7 +928,7 @@ float fms = org.apache.lucene.search.FuzzyQuery.defaultMaxEdits;break;}default:- jj_la1[20] = jj_gen;+ jj_la1[23] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -880,7 +947,7 @@ operator = token;break;}default:- jj_la1[21] = jj_gen;+ jj_la1[24] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -941,7 +1008,7 @@ String v = term.image.substring(1, term.image.length() - 1);break;}default:- jj_la1[22] = jj_gen;+ jj_la1[25] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -952,7 +1019,7 @@ q = new FieldQueryNode(field, discardEscapeChar(term.image), term.beginColumn, tbreak;}default:- jj_la1[23] = jj_gen;+ jj_la1[26] = jj_gen;;}break;@@ -967,7 +1034,7 @@ q = new FieldQueryNode(field, discardEscapeChar(term.image), term.beginColumn, tbreak;}default:- jj_la1[24] = jj_gen;+ jj_la1[27] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -977,7 +1044,7 @@ q = new FieldQueryNode(field, discardEscapeChar(term.image), term.beginColumn, tbreak;}default:- jj_la1[25] = jj_gen;+ jj_la1[28] = jj_gen;;}{if ("" != null) return q;}@@ -997,7 +1064,7 @@ q = new SlopQueryNode(q, parseInt(slop));break;}default:- jj_la1[26] = jj_gen;+ jj_la1[29] = jj_gen;;}{if ("" != null) return q;}@@ -1018,7 +1085,7 @@ leftInclusive = true;break;}default:- jj_la1[27] = jj_gen;+ jj_la1[30] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -1036,7 +1103,7 @@ leftInclusive = true;break;}default:- jj_la1[28] = jj_gen;+ jj_la1[31] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -1056,7 +1123,7 @@ left = token;break;}default:- jj_la1[29] = jj_gen;+ jj_la1[32] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -1072,7 +1139,7 @@ rightInclusive = true;break;}default:- jj_la1[30] = jj_gen;+ jj_la1[33] = jj_gen;jj_consume_token(-1);throw new ParseException();}@@ -1292,39 +1359,28 @@ if (left.kind == RANGE_QUOTED) {finally { jj_save(24, xla); }}- private boolean jj_3R_39()- {- Token xsp;- xsp = jj_scanpos;- if (jj_scan_token(25)) {- jj_scanpos = xsp;- if (jj_scan_token(24)) return true;- }- return false;- }-- private boolean jj_3R_38()+ private boolean jj_2_26(int xla){- if (jj_scan_token(QUOTED)) return true;- return false;+ jj_la = xla; jj_lastpos = jj_scanpos = token;+ try { return (!jj_3_26()); }+ catch(LookaheadSuccess ls) { return true; }+ finally { jj_save(25, xla); }}- private boolean jj_3R_32()+ private boolean jj_2_27(int xla){- Token xsp;- xsp = jj_scanpos;- if (jj_3R_38()) {- jj_scanpos = xsp;- if (jj_3R_39()) return true;- }- return false;+ jj_la = xla; jj_lastpos = jj_scanpos = token;+ try { return (!jj_3_27()); }+ catch(LookaheadSuccess ls) { return true; }+ finally { jj_save(26, xla); }}- private boolean jj_3R_26()+ private boolean jj_2_28(int xla){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(NOT_CONTAINED_BY)) return true;- return false;+ jj_la = xla; jj_lastpos = jj_scanpos = token;+ try { return (!jj_3_28()); }+ catch(LookaheadSuccess ls) { return true; }+ finally { jj_save(27, xla); }}private boolean jj_3R_17()@@ -1341,6 +1397,24 @@ if (left.kind == RANGE_QUOTED) {return false;}+ private boolean jj_3R_11()+ {+ if (jj_3R_9()) return true;+ Token xsp;+ xsp = jj_scanpos;+ if (jj_scan_token(17)) {+ jj_scanpos = xsp;+ if (jj_scan_token(18)) {+ jj_scanpos = xsp;+ if (jj_scan_token(19)) {+ jj_scanpos = xsp;+ if (jj_scan_token(20)) return true;+ }+ }+ }+ return false;+ }+private boolean jj_3R_19(){if (jj_scan_token(FN_PREFIX)) return true;@@ -1348,9 +1422,9 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_45()+ private boolean jj_3R_47(){- if (jj_scan_token(RANGEIN_START)) return true;+ if (jj_scan_token(TILDE)) return true;return false;}@@ -1361,29 +1435,19 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_41()+ private boolean jj_3R_24(){- Token xsp;- xsp = jj_scanpos;- if (jj_3R_45()) {- jj_scanpos = xsp;- if (jj_scan_token(28)) return true;- }- xsp = jj_scanpos;- if (jj_scan_token(54)) {- jj_scanpos = xsp;- if (jj_scan_token(53)) {- jj_scanpos = xsp;- if (jj_scan_token(50)) return true;- }- }+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(NOT_CONTAINING)) return true;return false;}- private boolean jj_3R_24()+ private boolean jj_3R_43(){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(NOT_CONTAINING)) return true;+ if (jj_scan_token(QUOTED)) return true;+ Token xsp;+ xsp = jj_scanpos;+ if (jj_3R_47()) jj_scanpos = xsp;return false;}@@ -1401,6 +1465,12 @@ if (left.kind == RANGE_QUOTED) {return false;}+ private boolean jj_3_28()+ {+ if (jj_scan_token(NUMBER)) return true;+ return false;+ }+private boolean jj_3R_23(){if (jj_scan_token(FN_PREFIX)) return true;@@ -1421,59 +1491,78 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_11()+ private boolean jj_3R_41(){- if (jj_3R_9()) return true;- Token xsp;- xsp = jj_scanpos;- if (jj_scan_token(17)) {- jj_scanpos = xsp;- if (jj_scan_token(18)) {- jj_scanpos = xsp;- if (jj_scan_token(19)) {- jj_scanpos = xsp;- if (jj_scan_token(20)) return true;- }- }- }+ if (jj_3R_45()) return true;return false;}- private boolean jj_3R_46()+ private boolean jj_3R_37()+ {+ if (jj_3R_43()) return true;+ return false;+ }++ private boolean jj_3R_45(){if (jj_scan_token(TILDE)) return true;return false;}+ private boolean jj_3R_38()+ {+ if (jj_3R_44()) return true;+ return false;+ }++ private boolean jj_3R_36()+ {+ if (jj_3R_42()) return true;+ return false;+ }+private boolean jj_3_2(){if (jj_3R_10()) return true;return false;}- private boolean jj_3_1()+ private boolean jj_3R_13()+ {+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(MAXWIDTH)) return true;+ return false;+ }++ private boolean jj_3R_35(){- if (jj_3R_9()) return true;Token xsp;xsp = jj_scanpos;- if (jj_scan_token(15)) {+ if (jj_scan_token(25)) {jj_scanpos = xsp;- if (jj_scan_token(16)) return true;+ if (jj_scan_token(24)) return true;}+ xsp = jj_scanpos;+ if (jj_3R_41()) jj_scanpos = xsp;return false;}- private boolean jj_3R_13()+ private boolean jj_3R_20(){if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(MAXWIDTH)) return true;+ if (jj_scan_token(AFTER)) return true;return false;}- private boolean jj_3R_20()+ private boolean jj_3_1(){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(AFTER)) return true;+ if (jj_3R_9()) return true;+ Token xsp;+ xsp = jj_scanpos;+ if (jj_scan_token(15)) {+ jj_scanpos = xsp;+ if (jj_scan_token(16)) return true;+ }return false;}@@ -1483,12 +1572,9 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_42()+ private boolean jj_3R_34(){- if (jj_scan_token(QUOTED)) return true;- Token xsp;- xsp = jj_scanpos;- if (jj_3R_46()) jj_scanpos = xsp;+ if (jj_scan_token(REGEXPTERM)) return true;return false;}@@ -1506,40 +1592,53 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_12()+ private boolean jj_3R_10(){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(ATLEAST)) return true;+ Token xsp;+ xsp = jj_scanpos;+ if (jj_3R_34()) {+ jj_scanpos = xsp;+ if (jj_3R_35()) {+ jj_scanpos = xsp;+ if (jj_3R_36()) {+ jj_scanpos = xsp;+ if (jj_3R_37()) return true;+ }+ }+ }+ xsp = jj_scanpos;+ if (jj_3R_38()) jj_scanpos = xsp;return false;}- private boolean jj_3_25()+ private boolean jj_3R_12(){- if (jj_scan_token(NUMBER)) return true;+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(ATLEAST)) return true;return false;}- private boolean jj_3_24()+ private boolean jj_3R_44(){- if (jj_3R_32()) return true;+ if (jj_scan_token(CARAT)) return true;return false;}- private boolean jj_3_23()+ private boolean jj_3_25(){- if (jj_3R_31()) return true;+ if (jj_3R_33()) return true;return false;}- private boolean jj_3R_40()+ private boolean jj_3_24(){- if (jj_3R_44()) return true;+ if (jj_3R_32()) return true;return false;}- private boolean jj_3R_36()+ private boolean jj_3_23(){- if (jj_3R_42()) return true;+ if (jj_3R_31()) return true;return false;}@@ -1549,27 +1648,16 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_44()- {- if (jj_scan_token(TILDE)) return true;- return false;- }-- private boolean jj_3R_37()- {- if (jj_3R_43()) return true;- return false;- }-- private boolean jj_3R_35()+ private boolean jj_3_21(){- if (jj_3R_41()) return true;+ if (jj_3R_29()) return true;return false;}- private boolean jj_3_21()+ private boolean jj_3R_22(){- if (jj_3R_29()) return true;+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(PHRASE)) return true;return false;}@@ -1579,10 +1667,10 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_22()+ private boolean jj_3R_31(){if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(PHRASE)) return true;+ if (jj_scan_token(EXTEND)) return true;return false;}@@ -1592,7 +1680,13 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_34()+ private boolean jj_3_18()+ {+ if (jj_3R_26()) return true;+ return false;+ }++ private boolean jj_3R_40(){Token xsp;xsp = jj_scanpos;@@ -1600,27 +1694,29 @@ if (left.kind == RANGE_QUOTED) {jj_scanpos = xsp;if (jj_scan_token(24)) return true;}- xsp = jj_scanpos;- if (jj_3R_40()) jj_scanpos = xsp;return false;}- private boolean jj_3R_31()+ private boolean jj_3_17(){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(EXTEND)) return true;+ if (jj_3R_25()) return true;return false;}- private boolean jj_3_18()+ private boolean jj_3R_39(){- if (jj_3R_26()) return true;+ if (jj_scan_token(QUOTED)) return true;return false;}- private boolean jj_3_17()+ private boolean jj_3R_33(){- if (jj_3R_25()) return true;+ Token xsp;+ xsp = jj_scanpos;+ if (jj_3R_39()) {+ jj_scanpos = xsp;+ if (jj_3R_40()) return true;+ }return false;}@@ -1642,12 +1738,6 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_33()- {- if (jj_scan_token(REGEXPTERM)) return true;- return false;- }-private boolean jj_3_13(){if (jj_3R_21()) return true;@@ -1678,6 +1768,13 @@ if (left.kind == RANGE_QUOTED) {return false;}+ private boolean jj_3R_18()+ {+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(FN_OR)) return true;+ return false;+ }+private boolean jj_3_8(){if (jj_3R_16()) return true;@@ -1690,60 +1787,46 @@ if (left.kind == RANGE_QUOTED) {return false;}- private boolean jj_3R_18()+ private boolean jj_3_6(){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(FN_OR)) return true;+ if (jj_3R_14()) return true;return false;}- private boolean jj_3R_10()+ private boolean jj_3_5(){- Token xsp;- xsp = jj_scanpos;- if (jj_3R_33()) {- jj_scanpos = xsp;- if (jj_3R_34()) {- jj_scanpos = xsp;- if (jj_3R_35()) {- jj_scanpos = xsp;- if (jj_3R_36()) return true;- }- }- }- xsp = jj_scanpos;- if (jj_3R_37()) jj_scanpos = xsp;+ if (jj_3R_13()) return true;return false;}- private boolean jj_3_6()+ private boolean jj_3_4(){- if (jj_3R_14()) return true;+ if (jj_3R_12()) return true;return false;}- private boolean jj_3_5()+ private boolean jj_3_27(){- if (jj_3R_13()) return true;+ if (jj_scan_token(NUMBER)) return true;return false;}- private boolean jj_3R_43()+ private boolean jj_3R_27(){- if (jj_scan_token(CARAT)) return true;+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(WITHIN)) return true;return false;}- private boolean jj_3_4()+ private boolean jj_3_26(){- if (jj_3R_12()) return true;+ if (jj_scan_token(NUMBER)) return true;return false;}- private boolean jj_3R_27()+ private boolean jj_3R_46(){- if (jj_scan_token(FN_PREFIX)) return true;- if (jj_scan_token(WITHIN)) return true;+ if (jj_scan_token(RANGEIN_START)) return true;return false;}@@ -1754,6 +1837,39 @@ if (left.kind == RANGE_QUOTED) {return false;}+ private boolean jj_3R_32()+ {+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(FUZZYTERM)) return true;+ return false;+ }++ private boolean jj_3R_42()+ {+ Token xsp;+ xsp = jj_scanpos;+ if (jj_3R_46()) {+ jj_scanpos = xsp;+ if (jj_scan_token(28)) return true;+ }+ xsp = jj_scanpos;+ if (jj_scan_token(55)) {+ jj_scanpos = xsp;+ if (jj_scan_token(54)) {+ jj_scanpos = xsp;+ if (jj_scan_token(51)) return true;+ }+ }+ return false;+ }++ private boolean jj_3R_26()+ {+ if (jj_scan_token(FN_PREFIX)) return true;+ if (jj_scan_token(NOT_CONTAINED_BY)) return true;+ return false;+ }+/** Generated Token Manager. */public StandardSyntaxParserTokenManager token_source;/** Current token. */@@ -1764,7 +1880,7 @@ if (left.kind == RANGE_QUOTED) {private Token jj_scanpos, jj_lastpos;private int jj_la;private int jj_gen;- final private int[] jj_la1 = new int[31];+ final private int[] jj_la1 = new int[34];static private int[] jj_la1_0;static private int[] jj_la1_1;static {@@ -1772,12 +1888,12 @@ if (left.kind == RANGE_QUOTED) {jj_la1_init_1();}private static void jj_la1_init_0() {- jj_la1_0 = new int[] {0x3f803c00,0x200,0x100,0x2400,0x3400,0x3400,0x18000,0x23800800,0x3f800800,0x200000,0x0,0x3800800,0x3800800,0x3800800,0x3800800,0x3800800,0x3000000,0x3800000,0x3000000,0x3800000,0x1e0000,0x3800000,0x3000000,0x400000,0x1f800000,0x200000,0x400000,0x18000000,0x0,0x0,0x0,};+ jj_la1_0 = new int[] {0x3f803c00,0x200,0x100,0x2400,0x3400,0x3400,0x18000,0x23800800,0x3f800800,0x200000,0x0,0x3800800,0x3800800,0x3800800,0x3800800,0x3800800,0x3000000,0x3800000,0x1000000,0x3000000,0x3800000,0x3000000,0x3800000,0x1e0000,0x3800000,0x3000000,0x400000,0x1f800000,0x200000,0x400000,0x18000000,0x0,0x0,0x0,};}private static void jj_la1_init_1() {- jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x800000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x640000,0x640000,0x180000,};+ jj_la1_1 = new int[] {0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1000000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xc80000,0xc80000,0x300000,};}- final private JJCalls[] jj_2_rtns = new JJCalls[25];+ final private JJCalls[] jj_2_rtns = new JJCalls[28];private boolean jj_rescan = false;private int jj_gc = 0;@@ -1787,7 +1903,7 @@ if (left.kind == RANGE_QUOTED) {token = new Token();jj_ntk = -1;jj_gen = 0;- for (int i = 0; i < 31; i++) jj_la1[i] = -1;+ for (int i = 0; i < 34; i++) jj_la1[i] = -1;for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();}@@ -1797,7 +1913,7 @@ if (left.kind == RANGE_QUOTED) {token = new Token();jj_ntk = -1;jj_gen = 0;- for (int i = 0; i < 31; i++) jj_la1[i] = -1;+ for (int i = 0; i < 34; i++) jj_la1[i] = -1;for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();}@@ -1807,7 +1923,7 @@ if (left.kind == RANGE_QUOTED) {token = new Token();jj_ntk = -1;jj_gen = 0;- for (int i = 0; i < 31; i++) jj_la1[i] = -1;+ for (int i = 0; i < 34; i++) jj_la1[i] = -1;for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();}@@ -1817,7 +1933,7 @@ if (left.kind == RANGE_QUOTED) {token = new Token();jj_ntk = -1;jj_gen = 0;- for (int i = 0; i < 31; i++) jj_la1[i] = -1;+ for (int i = 0; i < 34; i++) jj_la1[i] = -1;for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();}@@ -1943,12 +2059,12 @@ if (left.kind == RANGE_QUOTED) {/** Generate ParseException. */public ParseException generateParseException() {jj_expentries.clear();- boolean[] la1tokens = new boolean[56];+ boolean[] la1tokens = new boolean[57];if (jj_kind >= 0) {la1tokens[jj_kind] = true;jj_kind = -1;}- for (int i = 0; i < 31; i++) {+ for (int i = 0; i < 34; i++) {if (jj_la1[i] == jj_gen) {for (int j = 0; j < 32; j++) {if ((jj_la1_0[i] & (1<<j)) != 0) {@@ -1960,7 +2076,7 @@ if (left.kind == RANGE_QUOTED) {}}}- for (int i = 0; i < 56; i++) {+ for (int i = 0; i < 57; i++) {if (la1tokens[i]) {jj_expentry = new int[1];jj_expentry[0] = i;@@ -1995,7 +2111,7 @@ if (left.kind == RANGE_QUOTED) {private void jj_rescan_token() {jj_rescan = true;- for (int i = 0; i < 25; i++) {+ for (int i = 0; i < 28; i++) {try {JJCalls p = jj_2_rtns[i];@@ -2028,6 +2144,9 @@ if (left.kind == RANGE_QUOTED) {case 22: jj_3_23(); break;case 23: jj_3_24(); break;case 24: jj_3_25(); break;+ case 25: jj_3_26(); break;+ case 26: jj_3_27(); break;+ case 27: jj_3_28(); break;}}p = p.next;diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jjindex 194d056050e..7389ce659f0 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParser.jj@@ -58,6 +58,7 @@ import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.Before;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.ContainedBy;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.Containing;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.Extend;+import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.FuzzyTerm;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.IntervalFunction;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.MaxGaps;import org.apache.lucene.queryparser.flexible.standard.nodes.intervalfn.MaxWidth;@@ -176,6 +177,7 @@ PARSER_END(StandardSyntaxParser)| <CONTAINING: ("containing") >| <EXTEND: ("extend") >| <FN_OR: ("or") >+ | <FUZZYTERM: ("fuzzyterm" | "fuzzyTerm") >| <MAXGAPS: ("maxgaps" | "maxGaps") >| <MAXWIDTH: ("maxwidth" | "maxWidth") >| <NON_OVERLAPPING: ("nonOverlapping" | "nonoverlapping") >@@ -403,6 +405,7 @@ private IntervalFunction IntervalFun() : {| LOOKAHEAD(2) source = IntervalOverlapping() { return source; }| LOOKAHEAD(2) source = IntervalNonOverlapping() { return source; }| LOOKAHEAD(2) source = IntervalExtend() { return source; }+ | LOOKAHEAD(2) source = IntervalFuzzyTerm() { return source; }| LOOKAHEAD(2) source = IntervalText() { return source; }}@@ -638,6 +641,7 @@ private IntervalFunction IntervalNonOverlapping() : {private IntervalFunction IntervalWildcard() : {String wildcard;+ Token maxExpansions = null;}{<FN_PREFIX> <WILDCARD>@@ -646,9 +650,32 @@ private IntervalFunction IntervalWildcard() : {(<TERM> | <NUMBER>) { wildcard = token.image; }| <QUOTED> { wildcard = token.image.substring(1, token.image.length() - 1); })+ (maxExpansions = <NUMBER>)?<RPAREN>{- return new Wildcard(wildcard);+ return new Wildcard(wildcard, maxExpansions == null ? 0 : parseInt(maxExpansions));+ }+}++private IntervalFunction IntervalFuzzyTerm() : {+ String term;+ Token maxEdits = null;+ Token maxExpansions = null;+}+{+ <FN_PREFIX> <FUZZYTERM>+ <LPAREN>+ (+ (<TERM> | <NUMBER>) { term = token.image; }+ | <QUOTED> { term = token.image.substring(1, token.image.length() - 1); }+ )+ (LOOKAHEAD(2) maxEdits = <NUMBER>)?+ (LOOKAHEAD(2) maxExpansions = <NUMBER>)?+ <RPAREN>+ {+ return new FuzzyTerm(term,+ maxEdits == null ? null : parseInt(maxEdits),+ maxExpansions == null ? null : parseInt(maxExpansions));}}diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.javaindex cdd241a13fe..b8868689d3e 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserConstants.java@@ -81,41 +81,43 @@ public interface StandardSyntaxParserConstants {/** RegularExpression Id. */int FN_OR = 36;/** RegularExpression Id. */- int MAXGAPS = 37;+ int FUZZYTERM = 37;/** RegularExpression Id. */- int MAXWIDTH = 38;+ int MAXGAPS = 38;/** RegularExpression Id. */- int NON_OVERLAPPING = 39;+ int MAXWIDTH = 39;/** RegularExpression Id. */- int NOT_CONTAINED_BY = 40;+ int NON_OVERLAPPING = 40;/** RegularExpression Id. */- int NOT_CONTAINING = 41;+ int NOT_CONTAINED_BY = 41;/** RegularExpression Id. */- int NOT_WITHIN = 42;+ int NOT_CONTAINING = 42;/** RegularExpression Id. */- int ORDERED = 43;+ int NOT_WITHIN = 43;/** RegularExpression Id. */- int OVERLAPPING = 44;+ int ORDERED = 44;/** RegularExpression Id. */- int PHRASE = 45;+ int OVERLAPPING = 45;/** RegularExpression Id. */- int UNORDERED = 46;+ int PHRASE = 46;/** RegularExpression Id. */- int UNORDERED_NO_OVERLAPS = 47;+ int UNORDERED = 47;/** RegularExpression Id. */- int WILDCARD = 48;+ int UNORDERED_NO_OVERLAPS = 48;/** RegularExpression Id. */- int WITHIN = 49;+ int WILDCARD = 49;/** RegularExpression Id. */- int RANGE_TO = 50;+ int WITHIN = 50;/** RegularExpression Id. */- int RANGEIN_END = 51;+ int RANGE_TO = 51;/** RegularExpression Id. */- int RANGEEX_END = 52;+ int RANGEIN_END = 52;/** RegularExpression Id. */- int RANGE_QUOTED = 53;+ int RANGEEX_END = 53;/** RegularExpression Id. */- int RANGE_GOOP = 54;+ int RANGE_QUOTED = 54;+ /** RegularExpression Id. */+ int RANGE_GOOP = 55;/** Lexical state. */int Function = 0;@@ -163,6 +165,7 @@ public interface StandardSyntaxParserConstants {"\"containing\"","\"extend\"","\"or\"",+ "<FUZZYTERM>","<MAXGAPS>","<MAXWIDTH>","<NON_OVERLAPPING>",diff --git a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.javaindex e757f74ce4e..a60b13ec246 100644--- a/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java+++ b/lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/standard/parser/StandardSyntaxParserTokenManager.java@@ -67,6 +67,7 @@ package org.apache.lucene.queryparser.flexible.standard.parser;+/** Token Manager. */@@ -129,7 +130,7 @@ private int jjMoveStringLiteralDfa0_2(){jjmatchedKind = 19;return jjMoveStringLiteralDfa1_2(0x100000L);case 64:- return jjStopAtPos(0, 55);+ return jjStopAtPos(0, 56);case 91:return jjStopAtPos(0, 27);case 94:@@ -526,55 +527,55 @@ private final int jjStopStringLiteralDfa_0(int pos, long active0){switch (pos){case 0:- if ((active0 & 0x400000000000L) != 0L)+ if ((active0 & 0x800000000000L) != 0L)return 19;- if ((active0 & 0x400000000L) != 0L)- return 47;if ((active0 & 0x80000000L) != 0L)+ return 79;+ if ((active0 & 0x400000000L) != 0L)return 63;return -1;case 1:- if ((active0 & 0x400000000000L) != 0L)- return 18;if ((active0 & 0x400000000L) != 0L)- return 46;+ return 62;+ if ((active0 & 0x800000000000L) != 0L)+ return 18;return -1;case 2:- if ((active0 & 0x400000000000L) != 0L)+ if ((active0 & 0x800000000000L) != 0L)return 17;if ((active0 & 0x400000000L) != 0L)- return 45;+ return 61;return -1;case 3:if ((active0 & 0x400000000L) != 0L)- return 44;- if ((active0 & 0x400000000000L) != 0L)+ return 60;+ if ((active0 & 0x800000000000L) != 0L)return 16;return -1;case 4:- if ((active0 & 0x400000000000L) != 0L)+ if ((active0 & 0x800000000000L) != 0L)return 15;if ((active0 & 0x400000000L) != 0L)- return 43;+ return 59;return -1;case 5:if ((active0 & 0x400000000L) != 0L)- return 42;- if ((active0 & 0x400000000000L) != 0L)+ return 58;+ if ((active0 & 0x800000000000L) != 0L)return 14;return -1;case 6:- if ((active0 & 0x400000000000L) != 0L)+ if ((active0 & 0x800000000000L) != 0L)return 13;if ((active0 & 0x400000000L) != 0L)- return 41;+ return 57;return -1;case 7:- if ((active0 & 0x400000000000L) != 0L)+ if ((active0 & 0x800000000000L) != 0L)return 12;return -1;case 8:- if ((active0 & 0x400000000000L) != 0L)+ if ((active0 & 0x800000000000L) != 0L)return 11;return -1;default :@@ -598,13 +599,13 @@ private int jjMoveStringLiteralDfa0_0(){case 101:return jjMoveStringLiteralDfa1_0(0x800000000L);case 111:- return jjMoveStringLiteralDfa1_0(0x181000000000L);+ return jjMoveStringLiteralDfa1_0(0x301000000000L);case 112:- return jjMoveStringLiteralDfa1_0(0x200000000000L);- case 117:return jjMoveStringLiteralDfa1_0(0x400000000000L);+ case 117:+ return jjMoveStringLiteralDfa1_0(0x800000000000L);case 119:- return jjMoveStringLiteralDfa1_0(0x3000000000000L);+ return jjMoveStringLiteralDfa1_0(0x6000000000000L);default :return jjMoveNfa_0(0, 0);}@@ -622,11 +623,11 @@ private int jjMoveStringLiteralDfa1_0(long active0){case 102:return jjMoveStringLiteralDfa2_0(active0, 0x80000000L);case 104:- return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L);+ return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L);case 105:- return jjMoveStringLiteralDfa2_0(active0, 0x3000000000000L);+ return jjMoveStringLiteralDfa2_0(active0, 0x6000000000000L);case 110:- return jjMoveStringLiteralDfa2_0(active0, 0x400000000000L);+ return jjMoveStringLiteralDfa2_0(active0, 0x800000000000L);case 111:return jjMoveStringLiteralDfa2_0(active0, 0x400000000L);case 114:@@ -635,9 +636,9 @@ private int jjMoveStringLiteralDfa1_0(long active0){jjmatchedKind = 36;jjmatchedPos = 1;}- return jjMoveStringLiteralDfa2_0(active0, 0x80000000000L);- case 118:return jjMoveStringLiteralDfa2_0(active0, 0x100000000000L);+ case 118:+ return jjMoveStringLiteralDfa2_0(active0, 0x200000000000L);case 120:return jjMoveStringLiteralDfa2_0(active0, 0x800000000L);default :@@ -656,21 +657,21 @@ private int jjMoveStringLiteralDfa2_0(long old0, long active0){switch(curChar){case 100:- return jjMoveStringLiteralDfa3_0(active0, 0x80000000000L);- case 101:return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L);+ case 101:+ return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L);case 102:return jjMoveStringLiteralDfa3_0(active0, 0x100000000L);case 108:- return jjMoveStringLiteralDfa3_0(active0, 0x1000000000000L);+ return jjMoveStringLiteralDfa3_0(active0, 0x2000000000000L);case 110:return jjMoveStringLiteralDfa3_0(active0, 0x400000000L);case 111:- return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L);+ return jjMoveStringLiteralDfa3_0(active0, 0x800000000000L);case 114:- return jjMoveStringLiteralDfa3_0(active0, 0x200000000000L);+ return jjMoveStringLiteralDfa3_0(active0, 0x400000000000L);case 116:- return jjMoveStringLiteralDfa3_0(active0, 0x2000880000000L);+ return jjMoveStringLiteralDfa3_0(active0, 0x4000880000000L);default :break;}@@ -687,17 +688,17 @@ private int jjMoveStringLiteralDfa3_0(long old0, long active0){switch(curChar){case 97:- return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L);+ return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L);case 100:- return jjMoveStringLiteralDfa4_0(active0, 0x1000000000000L);+ return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L);case 101:- return jjMoveStringLiteralDfa4_0(active0, 0x80880000000L);+ return jjMoveStringLiteralDfa4_0(active0, 0x100880000000L);case 104:- return jjMoveStringLiteralDfa4_0(active0, 0x2000000000000L);+ return jjMoveStringLiteralDfa4_0(active0, 0x4000000000000L);case 111:return jjMoveStringLiteralDfa4_0(active0, 0x100000000L);case 114:- return jjMoveStringLiteralDfa4_0(active0, 0x500000000000L);+ return jjMoveStringLiteralDfa4_0(active0, 0xa00000000000L);case 116:return jjMoveStringLiteralDfa4_0(active0, 0x400000000L);default :@@ -718,21 +719,21 @@ private int jjMoveStringLiteralDfa4_0(long old0, long active0){case 97:return jjMoveStringLiteralDfa5_0(active0, 0x400000000L);case 99:- return jjMoveStringLiteralDfa5_0(active0, 0x1000000000000L);+ return jjMoveStringLiteralDfa5_0(active0, 0x2000000000000L);case 100:- return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L);+ return jjMoveStringLiteralDfa5_0(active0, 0x800000000000L);case 105:- return jjMoveStringLiteralDfa5_0(active0, 0x2000000000000L);+ return jjMoveStringLiteralDfa5_0(active0, 0x4000000000000L);case 108:- return jjMoveStringLiteralDfa5_0(active0, 0x100000000000L);+ return jjMoveStringLiteralDfa5_0(active0, 0x200000000000L);case 110:return jjMoveStringLiteralDfa5_0(active0, 0x800000000L);case 114:if ((active0 & 0x80000000L) != 0L)return jjStopAtPos(4, 31);- return jjMoveStringLiteralDfa5_0(active0, 0x80100000000L);+ return jjMoveStringLiteralDfa5_0(active0, 0x100100000000L);case 115:- return jjMoveStringLiteralDfa5_0(active0, 0x200000000000L);+ return jjMoveStringLiteralDfa5_0(active0, 0x400000000000L);default :break;}@@ -749,7 +750,7 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0){switch(curChar){case 97:- return jjMoveStringLiteralDfa6_0(active0, 0x1100000000000L);+ return jjMoveStringLiteralDfa6_0(active0, 0x2200000000000L);case 100:if ((active0 & 0x800000000L) != 0L)return jjStopAtPos(5, 35);@@ -757,14 +758,14 @@ private int jjMoveStringLiteralDfa5_0(long old0, long active0){case 101:if ((active0 & 0x100000000L) != 0L)return jjStopAtPos(5, 32);- else if ((active0 & 0x200000000000L) != 0L)- return jjStopAtPos(5, 45);- return jjMoveStringLiteralDfa6_0(active0, 0x480000000000L);+ else if ((active0 & 0x400000000000L) != 0L)+ return jjStopAtPos(5, 46);+ return jjMoveStringLiteralDfa6_0(active0, 0x900000000000L);case 105:return jjMoveStringLiteralDfa6_0(active0, 0x400000000L);case 110:- if ((active0 & 0x2000000000000L) != 0L)- return jjStopAtPos(5, 49);+ if ((active0 & 0x4000000000000L) != 0L)+ return jjStopAtPos(5, 50);break;default :break;@@ -782,15 +783,15 @@ private int jjMoveStringLiteralDfa6_0(long old0, long active0){switch(curChar){case 100:- if ((active0 & 0x80000000000L) != 0L)- return jjStopAtPos(6, 43);+ if ((active0 & 0x100000000000L) != 0L)+ return jjStopAtPos(6, 44);break;case 110:return jjMoveStringLiteralDfa7_0(active0, 0x400000000L);case 112:- return jjMoveStringLiteralDfa7_0(active0, 0x100000000000L);+ return jjMoveStringLiteralDfa7_0(active0, 0x200000000000L);case 114:- return jjMoveStringLiteralDfa7_0(active0, 0x1400000000000L);+ return jjMoveStringLiteralDfa7_0(active0, 0x2800000000000L);default :break;}@@ -807,15 +808,15 @@ private int jjMoveStringLiteralDfa7_0(long old0, long active0){switch(curChar){case 100:- if ((active0 & 0x1000000000000L) != 0L)- return jjStopAtPos(7, 48);+ if ((active0 & 0x2000000000000L) != 0L)+ return jjStopAtPos(7, 49);break;case 101:- return jjMoveStringLiteralDfa8_0(active0, 0x400000000000L);+ return jjMoveStringLiteralDfa8_0(active0, 0x800000000000L);case 105:return jjMoveStringLiteralDfa8_0(active0, 0x400000000L);case 112:- return jjMoveStringLiteralDfa8_0(active0, 0x100000000000L);+ return jjMoveStringLiteralDfa8_0(active0, 0x200000000000L);default :break;}@@ -832,11 +833,11 @@ private int jjMoveStringLiteralDfa8_0(long old0, long active0){switch(curChar){case 100:- if ((active0 & 0x400000000000L) != 0L)- return jjStartNfaWithStates_0(8, 46, 11);+ if ((active0 & 0x800000000000L) != 0L)+ return jjStartNfaWithStates_0(8, 47, 11);break;case 105:- return jjMoveStringLiteralDfa9_0(active0, 0x100000000000L);+ return jjMoveStringLiteralDfa9_0(active0, 0x200000000000L);case 110:return jjMoveStringLiteralDfa9_0(active0, 0x400000000L);default :@@ -859,7 +860,7 @@ private int jjMoveStringLiteralDfa9_0(long old0, long active0){return jjStopAtPos(9, 34);break;case 110:- return jjMoveStringLiteralDfa10_0(active0, 0x100000000000L);+ return jjMoveStringLiteralDfa10_0(active0, 0x200000000000L);default :break;}@@ -876,8 +877,8 @@ private int jjMoveStringLiteralDfa10_0(long old0, long active0){switch(curChar){case 103:- if ((active0 & 0x100000000000L) != 0L)- return jjStopAtPos(10, 44);+ if ((active0 & 0x200000000000L) != 0L)+ return jjStopAtPos(10, 45);break;default :break;@@ -895,7 +896,7 @@ private int jjStartNfaWithStates_0(int pos, int kind, int state)private int jjMoveNfa_0(int startState, int curPos){int startsAt = 0;- jjnewStateCnt = 183;+ jjnewStateCnt = 199;int i = 1;jjstateSet[0] = startState;int kind = 0x7fffffff;@@ -937,41 +938,41 @@ private int jjMoveNfa_0(int startState, int curPos)if (curChar == 101)jjstateSet[jjnewStateCnt++] = 12;break;+ case 60:+ if (curChar == 97)+ jjstateSet[jjnewStateCnt++] = 68;+ if (curChar == 97)+ jjstateSet[jjnewStateCnt++] = 59;+ break;case 19:if (curChar == 110)jjstateSet[jjnewStateCnt++] = 35;if (curChar == 110)jjstateSet[jjnewStateCnt++] = 18;break;- case 63:- if (curChar == 116)- jjstateSet[jjnewStateCnt++] = 67;- if (curChar == 116)- jjstateSet[jjnewStateCnt++] = 62;- break;- case 0:- if (curChar == 109)- { jjAddStates(6, 9); }- else if (curChar == 110)- { jjAddStates(10, 17); }- else if (curChar == 97)- { jjAddStates(18, 19); }- else if (curChar == 99)- { jjAddStates(20, 21); }- else if (curChar == 117)- { jjAddStates(22, 23); }+ case 57:+ if (curChar == 101)+ jjstateSet[jjnewStateCnt++] = 65;+ if (curChar == 101)+ jjstateSet[jjnewStateCnt++] = 56;break;- case 46:+ case 58:if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 54;+ jjstateSet[jjnewStateCnt++] = 66;if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 45;+ jjstateSet[jjnewStateCnt++] = 57;break;- case 41:- if (curChar == 101)- jjstateSet[jjnewStateCnt++] = 49;- if (curChar == 101)- jjstateSet[jjnewStateCnt++] = 40;+ case 59:+ if (curChar == 105)+ jjstateSet[jjnewStateCnt++] = 67;+ if (curChar == 105)+ jjstateSet[jjnewStateCnt++] = 58;+ break;+ case 61:+ if (curChar == 116)+ jjstateSet[jjnewStateCnt++] = 69;+ if (curChar == 116)+ jjstateSet[jjnewStateCnt++] = 60;break;case 14:if (curChar == 114)@@ -979,17 +980,11 @@ private int jjMoveNfa_0(int startState, int curPos)if (curChar == 114)jjstateSet[jjnewStateCnt++] = 13;break;- case 47:- if (curChar == 111)- jjstateSet[jjnewStateCnt++] = 55;- if (curChar == 111)- jjstateSet[jjnewStateCnt++] = 46;- break;- case 42:+ case 62:if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 50;+ jjstateSet[jjnewStateCnt++] = 70;if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 41;+ jjstateSet[jjnewStateCnt++] = 61;break;case 15:if (curChar == 101)@@ -997,11 +992,11 @@ private int jjMoveNfa_0(int startState, int curPos)if (curChar == 101)jjstateSet[jjnewStateCnt++] = 14;break;- case 43:- if (curChar == 105)- jjstateSet[jjnewStateCnt++] = 51;- if (curChar == 105)- jjstateSet[jjnewStateCnt++] = 42;+ case 63:+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 71;+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 62;break;case 16:if (curChar == 100)@@ -1009,11 +1004,19 @@ private int jjMoveNfa_0(int startState, int curPos)if (curChar == 100)jjstateSet[jjnewStateCnt++] = 15;break;- case 44:- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 52;- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 43;+ case 0:+ if (curChar == 109)+ { jjAddStates(6, 9); }+ else if (curChar == 110)+ { jjAddStates(10, 17); }+ else if (curChar == 97)+ { jjAddStates(18, 19); }+ else if (curChar == 99)+ { jjAddStates(20, 21); }+ else if (curChar == 102)+ { jjAddStates(22, 23); }+ else if (curChar == 117)+ { jjAddStates(24, 25); }break;case 11:if (curChar == 110)@@ -1027,11 +1030,11 @@ private int jjMoveNfa_0(int startState, int curPos)if (curChar == 114)jjstateSet[jjnewStateCnt++] = 16;break;- case 45:+ case 79:if (curChar == 116)- jjstateSet[jjnewStateCnt++] = 53;+ jjstateSet[jjnewStateCnt++] = 83;if (curChar == 116)- jjstateSet[jjnewStateCnt++] = 44;+ jjstateSet[jjnewStateCnt++] = 78;break;case 12:if (curChar == 100)@@ -1041,11 +1044,11 @@ private int jjMoveNfa_0(int startState, int curPos)break;case 1:if (curChar == 117)- { jjAddStates(22, 23); }+ { jjAddStates(24, 25); }break;case 2:- if (curChar == 115 && kind > 47)- kind = 47;+ if (curChar == 115 && kind > 48)+ kind = 48;break;case 3:case 20:@@ -1145,84 +1148,88 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 35;break;case 37:- if (curChar == 99)- { jjAddStates(20, 21); }+ if (curChar == 102)+ { jjAddStates(22, 23); }break;case 38:- if (curChar == 121 && kind > 33)- kind = 33;+ if (curChar == 109 && kind > 37)+ kind = 37;break;case 39:- if (curChar == 66)+ case 46:+ if (curChar == 114){ jjCheckNAdd(38); }break;case 40:- if (curChar == 100)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 39;break;+ case 41:+ if (curChar == 116)+ jjstateSet[jjnewStateCnt++] = 40;+ break;+ case 42:+ if (curChar == 121)+ jjstateSet[jjnewStateCnt++] = 41;+ break;+ case 43:+ if (curChar == 122)+ jjstateSet[jjnewStateCnt++] = 42;+ break;+ case 44:+ if (curChar == 122)+ jjstateSet[jjnewStateCnt++] = 43;+ break;+ case 45:+ if (curChar == 117)+ jjstateSet[jjnewStateCnt++] = 44;+ break;+ case 47:+ if (curChar == 101)+ jjstateSet[jjnewStateCnt++] = 46;+ break;case 48:- if (curChar == 98)- { jjCheckNAdd(38); }+ if (curChar == 84)+ jjstateSet[jjnewStateCnt++] = 47;break;case 49:- if (curChar == 100)+ if (curChar == 121)jjstateSet[jjnewStateCnt++] = 48;break;case 50:- if (curChar == 101)+ if (curChar == 122)jjstateSet[jjnewStateCnt++] = 49;break;case 51:- if (curChar == 110)+ if (curChar == 122)jjstateSet[jjnewStateCnt++] = 50;break;case 52:- if (curChar == 105)+ if (curChar == 117)jjstateSet[jjnewStateCnt++] = 51;break;case 53:- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 52;+ if (curChar == 99)+ { jjAddStates(20, 21); }break;case 54:- if (curChar == 116)- jjstateSet[jjnewStateCnt++] = 53;+ if (curChar == 121 && kind > 33)+ kind = 33;break;case 55:- if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 54;+ if (curChar == 66)+ { jjCheckNAdd(54); }break;case 56:- if (curChar == 111)+ if (curChar == 100)jjstateSet[jjnewStateCnt++] = 55;break;- case 57:- if (curChar == 97)- { jjAddStates(18, 19); }- break;- case 58:- if (curChar == 116 && kind > 30)- kind = 30;- break;- case 59:case 64:- if (curChar == 115)- { jjCheckNAdd(58); }- break;- case 60:- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 59;- break;- case 61:- if (curChar == 101)- jjstateSet[jjnewStateCnt++] = 60;- break;- case 62:- if (curChar == 108)- jjstateSet[jjnewStateCnt++] = 61;+ if (curChar == 98)+ { jjCheckNAdd(54); }break;case 65:- if (curChar == 97)+ if (curChar == 100)jjstateSet[jjnewStateCnt++] = 64;break;case 66:@@ -1230,192 +1237,185 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 65;break;case 67:- if (curChar == 76)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 66;break;case 68:- if (curChar == 116)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 67;break;case 69:- if (curChar == 110)- { jjAddStates(10, 17); }+ if (curChar == 97)+ jjstateSet[jjnewStateCnt++] = 68;break;case 70:- if (curChar == 103 && kind > 39)- kind = 39;+ if (curChar == 116)+ jjstateSet[jjnewStateCnt++] = 69;break;case 71:- case 83:if (curChar == 110)- { jjCheckNAdd(70); }+ jjstateSet[jjnewStateCnt++] = 70;break;case 72:- if (curChar == 105)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 71;break;case 73:- if (curChar == 112)- jjstateSet[jjnewStateCnt++] = 72;+ if (curChar == 97)+ { jjAddStates(18, 19); }break;case 74:- if (curChar == 112)- jjstateSet[jjnewStateCnt++] = 73;+ if (curChar == 116 && kind > 30)+ kind = 30;break;case 75:- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 74;+ case 80:+ if (curChar == 115)+ { jjCheckNAdd(74); }break;case 76:- if (curChar == 108)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 75;break;case 77:- if (curChar == 114)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 76;break;case 78:- if (curChar == 101)+ if (curChar == 108)jjstateSet[jjnewStateCnt++] = 77;break;- case 79:- if (curChar == 118)- jjstateSet[jjnewStateCnt++] = 78;- break;- case 80:- if (curChar == 79)- jjstateSet[jjnewStateCnt++] = 79;- break;case 81:- if (curChar == 110)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 80;break;case 82:- if (curChar == 111)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 81;break;+ case 83:+ if (curChar == 76)+ jjstateSet[jjnewStateCnt++] = 82;+ break;case 84:- if (curChar == 105)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 83;break;case 85:- if (curChar == 112)- jjstateSet[jjnewStateCnt++] = 84;+ if (curChar == 110)+ { jjAddStates(10, 17); }break;case 86:- if (curChar == 112)- jjstateSet[jjnewStateCnt++] = 85;+ if (curChar == 103 && kind > 40)+ kind = 40;break;case 87:- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 86;+ case 99:+ if (curChar == 110)+ { jjCheckNAdd(86); }break;case 88:- if (curChar == 108)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 87;break;case 89:- if (curChar == 114)+ if (curChar == 112)jjstateSet[jjnewStateCnt++] = 88;break;case 90:- if (curChar == 101)+ if (curChar == 112)jjstateSet[jjnewStateCnt++] = 89;break;case 91:- if (curChar == 118)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 90;break;case 92:- if (curChar == 111)+ if (curChar == 108)jjstateSet[jjnewStateCnt++] = 91;break;case 93:- if (curChar == 110)+ if (curChar == 114)jjstateSet[jjnewStateCnt++] = 92;break;case 94:- if (curChar == 111)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 93;break;case 95:- if (curChar == 121 && kind > 40)- kind = 40;+ if (curChar == 118)+ jjstateSet[jjnewStateCnt++] = 94;break;case 96:- if (curChar == 66)- { jjCheckNAdd(95); }+ if (curChar == 79)+ jjstateSet[jjnewStateCnt++] = 95;break;case 97:- if (curChar == 100)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 96;break;case 98:- if (curChar == 101)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 97;break;- case 99:- if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 98;- break;case 100:if (curChar == 105)jjstateSet[jjnewStateCnt++] = 99;break;case 101:- if (curChar == 97)+ if (curChar == 112)jjstateSet[jjnewStateCnt++] = 100;break;case 102:- if (curChar == 116)+ if (curChar == 112)jjstateSet[jjnewStateCnt++] = 101;break;case 103:- if (curChar == 110)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 102;break;case 104:- if (curChar == 111)+ if (curChar == 108)jjstateSet[jjnewStateCnt++] = 103;break;case 105:- if (curChar == 67)+ if (curChar == 114)jjstateSet[jjnewStateCnt++] = 104;break;case 106:- if (curChar == 116)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 105;break;case 107:- if (curChar == 111)+ if (curChar == 118)jjstateSet[jjnewStateCnt++] = 106;break;case 108:- if (curChar == 98)- { jjCheckNAdd(95); }+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 107;break;case 109:- if (curChar == 100)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 108;break;case 110:- if (curChar == 101)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 109;break;case 111:- if (curChar == 110)- jjstateSet[jjnewStateCnt++] = 110;+ if (curChar == 121 && kind > 41)+ kind = 41;break;case 112:- if (curChar == 105)- jjstateSet[jjnewStateCnt++] = 111;+ if (curChar == 66)+ { jjCheckNAdd(111); }break;case 113:- if (curChar == 97)+ if (curChar == 100)jjstateSet[jjnewStateCnt++] = 112;break;case 114:- if (curChar == 116)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 113;break;case 115:@@ -1423,11 +1423,11 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 114;break;case 116:- if (curChar == 111)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 115;break;case 117:- if (curChar == 99)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 116;break;case 118:@@ -1435,36 +1435,35 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 117;break;case 119:- if (curChar == 111)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 118;break;case 120:- if (curChar == 103 && kind > 41)- kind = 41;+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 119;break;case 121:- case 132:- if (curChar == 110)- { jjCheckNAdd(120); }+ if (curChar == 67)+ jjstateSet[jjnewStateCnt++] = 120;break;case 122:- if (curChar == 105)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 121;break;case 123:- if (curChar == 110)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 122;break;case 124:- if (curChar == 105)- jjstateSet[jjnewStateCnt++] = 123;+ if (curChar == 98)+ { jjCheckNAdd(111); }break;case 125:- if (curChar == 97)+ if (curChar == 100)jjstateSet[jjnewStateCnt++] = 124;break;case 126:- if (curChar == 116)+ if (curChar == 101)jjstateSet[jjnewStateCnt++] = 125;break;case 127:@@ -1472,11 +1471,11 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 126;break;case 128:- if (curChar == 111)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 127;break;case 129:- if (curChar == 67)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 128;break;case 130:@@ -1484,60 +1483,64 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 129;break;case 131:- if (curChar == 111)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 130;break;+ case 132:+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 131;+ break;case 133:- if (curChar == 105)+ if (curChar == 99)jjstateSet[jjnewStateCnt++] = 132;break;case 134:- if (curChar == 110)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 133;break;case 135:- if (curChar == 105)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 134;break;case 136:- if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 135;+ if (curChar == 103 && kind > 42)+ kind = 42;break;case 137:- if (curChar == 116)- jjstateSet[jjnewStateCnt++] = 136;+ case 148:+ if (curChar == 110)+ { jjCheckNAdd(136); }break;case 138:- if (curChar == 110)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 137;break;case 139:- if (curChar == 111)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 138;break;case 140:- if (curChar == 99)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 139;break;case 141:- if (curChar == 116)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 140;break;case 142:- if (curChar == 111)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 141;break;case 143:- if (curChar == 110 && kind > 42)- kind = 42;+ if (curChar == 110)+ jjstateSet[jjnewStateCnt++] = 142;break;case 144:- case 151:- if (curChar == 105)- { jjCheckNAdd(143); }+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 143;break;case 145:- if (curChar == 104)+ if (curChar == 67)jjstateSet[jjnewStateCnt++] = 144;break;case 146:@@ -1545,23 +1548,23 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 145;break;case 147:- if (curChar == 105)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 146;break;- case 148:- if (curChar == 87)- jjstateSet[jjnewStateCnt++] = 147;- break;case 149:- if (curChar == 116)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 148;break;case 150:- if (curChar == 111)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 149;break;+ case 151:+ if (curChar == 105)+ jjstateSet[jjnewStateCnt++] = 150;+ break;case 152:- if (curChar == 104)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 151;break;case 153:@@ -1569,115 +1572,176 @@ private int jjMoveNfa_0(int startState, int curPos)jjstateSet[jjnewStateCnt++] = 152;break;case 154:- if (curChar == 105)+ if (curChar == 110)jjstateSet[jjnewStateCnt++] = 153;break;case 155:- if (curChar == 119)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 154;break;case 156:- if (curChar == 116)+ if (curChar == 99)jjstateSet[jjnewStateCnt++] = 155;break;case 157:- if (curChar == 111)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 156;break;case 158:- if (curChar == 109)- { jjAddStates(6, 9); }+ if (curChar == 111)+ jjstateSet[jjnewStateCnt++] = 157;break;case 159:- if (curChar == 115 && kind > 37)- kind = 37;+ if (curChar == 110 && kind > 43)+ kind = 43;break;case 160:- case 165:- if (curChar == 112)+ case 167:+ if (curChar == 105){ jjCheckNAdd(159); }break;case 161:- if (curChar == 97)+ if (curChar == 104)jjstateSet[jjnewStateCnt++] = 160;break;case 162:- if (curChar == 103)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 161;break;case 163:- if (curChar == 120)+ if (curChar == 105)jjstateSet[jjnewStateCnt++] = 162;break;case 164:- if (curChar == 97)+ if (curChar == 87)jjstateSet[jjnewStateCnt++] = 163;break;+ case 165:+ if (curChar == 116)+ jjstateSet[jjnewStateCnt++] = 164;+ break;case 166:- if (curChar == 97)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 165;break;- case 167:- if (curChar == 71)- jjstateSet[jjnewStateCnt++] = 166;- break;case 168:- if (curChar == 120)+ if (curChar == 104)jjstateSet[jjnewStateCnt++] = 167;break;case 169:- if (curChar == 97)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 168;break;case 170:- if (curChar == 104 && kind > 38)- kind = 38;+ if (curChar == 105)+ jjstateSet[jjnewStateCnt++] = 169;break;case 171:- case 177:- if (curChar == 116)- { jjCheckNAdd(170); }+ if (curChar == 119)+ jjstateSet[jjnewStateCnt++] = 170;break;case 172:- if (curChar == 100)+ if (curChar == 116)jjstateSet[jjnewStateCnt++] = 171;break;case 173:- if (curChar == 105)+ if (curChar == 111)jjstateSet[jjnewStateCnt++] = 172;break;case 174:- if (curChar == 119)- jjstateSet[jjnewStateCnt++] = 173;+ if (curChar == 109)+ { jjAddStates(6, 9); }break;case 175:- if (curChar == 120)- jjstateSet[jjnewStateCnt++] = 174;+ if (curChar == 115 && kind > 38)+ kind = 38;break;case 176:+ case 181:+ if (curChar == 112)+ { jjCheckNAdd(175); }+ break;+ case 177:if (curChar == 97)- jjstateSet[jjnewStateCnt++] = 175;+ jjstateSet[jjnewStateCnt++] = 176;break;case 178:- if (curChar == 100)+ if (curChar == 103)jjstateSet[jjnewStateCnt++] = 177;break;case 179:- if (curChar == 105)+ if (curChar == 120)jjstateSet[jjnewStateCnt++] = 178;break;case 180:- if (curChar == 87)+ if (curChar == 97)jjstateSet[jjnewStateCnt++] = 179;break;- case 181:- if (curChar == 120)- jjstateSet[jjnewStateCnt++] = 180;- break;case 182:if (curChar == 97)jjstateSet[jjnewStateCnt++] = 181;break;+ case 183:+ if (curChar == 71)+ jjstateSet[jjnewStateCnt++] = 182;+ break;+ case 184:+ if (curChar == 120)+ jjstateSet[jjnewStateCnt++] = 183;+ break;+ case 185:+ if (curChar == 97)+ jjstateSet[jjnewStateCnt++] = 184;+ break;+ case 186:+ if (curChar == 104 && kind > 39)+ kind = 39;+ break;+ case 187:+ case 193:+ if (curChar == 116)+ { jjCheckNAdd(186); }+ break;+ case 188:+ if (curChar == 100)+ jjstateSet[jjnewStateCnt++] = 187;+ break;+ case 189:+ if (curChar == 105)+ jjstateSet[jjnewStateCnt++] = 188;+ break;+ case 190:+ if (curChar == 119)+ jjstateSet[jjnewStateCnt++] = 189;+ break;+ case 191:+ if (curChar == 120)+ jjstateSet[jjnewStateCnt++] = 190;+ break;+ case 192:+ if (curChar == 97)+ jjstateSet[jjnewStateCnt++] = 191;+ break;+ case 194:+ if (curChar == 100)+ jjstateSet[jjnewStateCnt++] = 193;+ break;+ case 195:+ if (curChar == 105)+ jjstateSet[jjnewStateCnt++] = 194;+ break;+ case 196:+ if (curChar == 87)+ jjstateSet[jjnewStateCnt++] = 195;+ break;+ case 197:+ if (curChar == 120)+ jjstateSet[jjnewStateCnt++] = 196;+ break;+ case 198:+ if (curChar == 97)+ jjstateSet[jjnewStateCnt++] = 197;+ break;default : break;}} while(i != startsAt);@@ -1708,7 +1772,7 @@ private int jjMoveNfa_0(int startState, int curPos)kind = 0x7fffffff;}++curPos;- if ((i = jjnewStateCnt) == (startsAt = 183 - (jjnewStateCnt = startsAt)))+ if ((i = jjnewStateCnt) == (startsAt = 199 - (jjnewStateCnt = startsAt)))return curPos;try { curChar = input_stream.readChar(); }catch(java.io.IOException e) { return curPos; }@@ -1718,9 +1782,9 @@ private final int jjStopStringLiteralDfa_1(int pos, long active0){switch (pos){case 0:- if ((active0 & 0x4000000000000L) != 0L)+ if ((active0 & 0x8000000000000L) != 0L){- jjmatchedKind = 54;+ jjmatchedKind = 55;return 6;}return -1;@@ -1735,11 +1799,11 @@ private int jjMoveStringLiteralDfa0_1(){switch(curChar){case 84:- return jjMoveStringLiteralDfa1_1(0x4000000000000L);+ return jjMoveStringLiteralDfa1_1(0x8000000000000L);case 93:- return jjStopAtPos(0, 51);- case 125:return jjStopAtPos(0, 52);+ case 125:+ return jjStopAtPos(0, 53);default :return jjMoveNfa_1(0, 0);}@@ -1753,8 +1817,8 @@ private int jjMoveStringLiteralDfa1_1(long active0){switch(curChar){case 79:- if ((active0 & 0x4000000000000L) != 0L)- return jjStartNfaWithStates_1(1, 50, 6);+ if ((active0 & 0x8000000000000L) != 0L)+ return jjStartNfaWithStates_1(1, 51, 6);break;default :break;@@ -1790,8 +1854,8 @@ private int jjMoveNfa_1(int startState, int curPos)case 0:if ((0xfffffffeffffffffL & l) != 0L){- if (kind > 54)- kind = 54;+ if (kind > 55)+ kind = 55;{ jjCheckNAdd(6); }}if ((0x100002600L & l) != 0L)@@ -1808,21 +1872,21 @@ private int jjMoveNfa_1(int startState, int curPos)break;case 2:if ((0xfffffffbffffffffL & l) != 0L)- { jjCheckNAddStates(24, 26); }+ { jjCheckNAddStates(26, 28); }break;case 3:if (curChar == 34)- { jjCheckNAddStates(24, 26); }+ { jjCheckNAddStates(26, 28); }break;case 5:- if (curChar == 34 && kind > 53)- kind = 53;+ if (curChar == 34 && kind > 54)+ kind = 54;break;case 6:if ((0xfffffffeffffffffL & l) == 0L)break;- if (kind > 54)- kind = 54;+ if (kind > 55)+ kind = 55;{ jjCheckNAdd(6); }break;default : break;@@ -1840,12 +1904,12 @@ private int jjMoveNfa_1(int startState, int curPos)case 6:if ((0xdfffffffdfffffffL & l) == 0L)break;- if (kind > 54)- kind = 54;+ if (kind > 55)+ kind = 55;{ jjCheckNAdd(6); }break;case 2:- { jjAddStates(24, 26); }+ { jjAddStates(26, 28); }break;case 4:if (curChar == 92)@@ -1874,20 +1938,20 @@ private int jjMoveNfa_1(int startState, int curPos)}if (jjCanMove_1(hiByte, i1, i2, l1, l2)){- if (kind > 54)- kind = 54;+ if (kind > 55)+ kind = 55;{ jjCheckNAdd(6); }}break;case 2:if (jjCanMove_1(hiByte, i1, i2, l1, l2))- { jjAddStates(24, 26); }+ { jjAddStates(26, 28); }break;case 6:if (!jjCanMove_1(hiByte, i1, i2, l1, l2))break;- if (kind > 54)- kind = 54;+ if (kind > 55)+ kind = 55;{ jjCheckNAdd(6); }break;default : if (i1 == 0 || l1 == 0 || i2 == 0 || l2 == 0) break; else break;@@ -1914,7 +1978,7 @@ public static final String[] jjstrLiteralImages = {"\53", "\55", "\51", "\72", "\75", "\74", "\74\75", "\76", "\76\75", "\136", "\176",null, null, null, null, "\133", "\173", "\50", null, "\141\146\164\145\162","\142\145\146\157\162\145", null, "\143\157\156\164\141\151\156\151\156\147", "\145\170\164\145\156\144",-"\157\162", null, null, null, null, null, null, "\157\162\144\145\162\145\144",+"\157\162", null, null, null, null, null, null, null, "\157\162\144\145\162\145\144","\157\166\145\162\154\141\160\160\151\156\147", "\160\150\162\141\163\145", "\165\156\157\162\144\145\162\145\144", null,"\167\151\154\144\143\141\162\144", "\167\151\164\150\151\156", "\124\117", "\135", "\175", null, null, "\100", };protected Token jjFillToken()@@ -1943,8 +2007,8 @@ protected Token jjFillToken()return t;}static final int[] jjnextStates = {- 28, 30, 31, 15, 16, 18, 164, 169, 176, 182, 82, 94, 107, 119, 131, 142,- 150, 157, 63, 68, 47, 56, 19, 36, 2, 4, 5,+ 28, 30, 31, 15, 16, 18, 180, 185, 192, 198, 98, 110, 123, 135, 147, 158,+ 166, 173, 79, 84, 63, 72, 45, 52, 19, 36, 2, 4, 5,};private static final boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2){@@ -2153,7 +2217,7 @@ private void jjCheckNAddStates(int start, int end){int i;jjround = 0x80000001;- for (i = 183; i-- > 0;)+ for (i = 199; i-- > 0;)jjrounds[i] = 0x80000000;}@@ -2186,10 +2250,10 @@ public static final String[] lexStateNames = {public static final int[] jjnewLexState = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,-1, -1, 1, 1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,- -1, 2, 2, -1, -1, -1,+ -1, -1, 2, 2, -1, -1, -1,};static final long[] jjtoToken = {- 0xffffffffffff01L,+ 0x1ffffffffffff01L,};static final long[] jjtoSkip = {0x80L,@@ -2202,8 +2266,8 @@ static final long[] jjtoMore = {};protected CharStream input_stream;- private final int[] jjrounds = new int[183];- private final int[] jjstateSet = new int[2 * 183];+ private final int[] jjrounds = new int[199];+ private final int[] jjstateSet = new int[2 * 199];private final StringBuilder jjimage = new StringBuilder();private StringBuilder image = jjimage;private int jjimageLen;diff --git a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestStandardQPEnhancements.java b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestStandardQPEnhancements.javaindex f22433371fb..5bc09a89bb2 100644--- a/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestStandardQPEnhancements.java+++ b/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestStandardQPEnhancements.java@@ -106,6 +106,9 @@ public class TestStandardQPEnhancements extends LuceneTestCase {@Testpublic void testWildcard() throws Exception {checkIntervalQueryNode("fn:wildcard(foo*)");++ // Explicit maxExpansions.+ checkIntervalQueryNode("fn:wildcard(foo* 128)");}@Test@@ -173,6 +176,15 @@ public class TestStandardQPEnhancements extends LuceneTestCase {checkIntervalQueryNode("fn:extend(fn:ordered(big foo) 2 5)");}+ @Test+ public void testFuzzy() throws Exception {+ checkIntervalQueryNode("fn:fuzzyTerm(dfe)");+ // Explicit maxEdits+ checkIntervalQueryNode("fn:fuzzyTerm(dfe 2)");+ // Explicit maxExpansions+ checkIntervalQueryNode("fn:fuzzyTerm(dfe 2 128)");+ }+protected void checkIntervalQueryNode(String query) throws Exception {// Check raw parser first.var syntaxParser = new StandardSyntaxParser(new FastCharStream(new StringReader(query)));diff --git a/lucene/test-framework/src/java/org/apache/lucene/tests/search/CheckHits.java b/lucene/test-framework/src/java/org/apache/lucene/tests/search/CheckHits.javaindex 7936490523b..eacd3440e0d 100644--- a/lucene/test-framework/src/java/org/apache/lucene/tests/search/CheckHits.java+++ b/lucene/test-framework/src/java/org/apache/lucene/tests/search/CheckHits.java@@ -144,7 +144,7 @@ public class CheckHits {}/**- * Tests that a query matches the an expected set of documents using Hits.+ * Tests that a query matches the expected set of documents using Hits.** <p>Note that when using the Hits API, documents will only be returned if they have a positive* normalized score.@@ -159,16 +159,16 @@ public class CheckHits {Random random, Query query, String defaultFieldName, IndexSearcher searcher, int[] results)throws IOException {- ScoreDoc[] hits = searcher.search(query, 1000).scoreDocs;+ ScoreDoc[] hits = searcher.search(query, Math.max(10, results.length * 2)).scoreDocs;Set<Integer> correct = new TreeSet<>();- for (int i = 0; i < results.length; i++) {- correct.add(Integer.valueOf(results[i]));+ for (int result : results) {+ correct.add(result);}Set<Integer> actual = new TreeSet<>();- for (int i = 0; i < hits.length; i++) {- actual.add(Integer.valueOf(hits[i].doc));+ for (ScoreDoc hit : hits) {+ actual.add(hit.doc);}assertEquals(query.toString(defaultFieldName), correct, actual);