diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java index bd4d783f57a..3187845cadd 100644 --- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java +++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggester.java @@ -190,19 +190,19 @@ public class AnalyzingSuggester extends Lookup { /** * Calls {@link #AnalyzingSuggester(Analyzer,Analyzer,int,int,int,boolean) * AnalyzingSuggester(analyzer, analyzer, EXACT_FIRST | - * PRESERVE_SEP, 256, -1, false)} + * PRESERVE_SEP, 256, -1, true)} */ public AnalyzingSuggester(Analyzer analyzer) { - this(analyzer, analyzer, EXACT_FIRST | PRESERVE_SEP, 256, -1, false); + this(analyzer, analyzer, EXACT_FIRST | PRESERVE_SEP, 256, -1, true); } /** * Calls {@link #AnalyzingSuggester(Analyzer,Analyzer,int,int,int,boolean) * AnalyzingSuggester(indexAnalyzer, queryAnalyzer, EXACT_FIRST | - * PRESERVE_SEP, 256, -1, false)} + * PRESERVE_SEP, 256, -1, true)} */ public AnalyzingSuggester(Analyzer indexAnalyzer, Analyzer queryAnalyzer) { - this(indexAnalyzer, queryAnalyzer, EXACT_FIRST | PRESERVE_SEP, 256, -1, false); + this(indexAnalyzer, queryAnalyzer, EXACT_FIRST | PRESERVE_SEP, 256, -1, true); } /** diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FuzzySuggester.java b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FuzzySuggester.java index f319c82c47a..63a26e20245 100644 --- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FuzzySuggester.java +++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/FuzzySuggester.java @@ -124,7 +124,7 @@ public final class FuzzySuggester extends AnalyzingSuggester { * Analyzer that will be used for analyzing query text during lookup */ public FuzzySuggester(Analyzer indexAnalyzer, Analyzer queryAnalyzer) { - this(indexAnalyzer, queryAnalyzer, EXACT_FIRST | PRESERVE_SEP, 256, -1, false, DEFAULT_MAX_EDITS, DEFAULT_TRANSPOSITIONS, + this(indexAnalyzer, queryAnalyzer, EXACT_FIRST | PRESERVE_SEP, 256, -1, true, DEFAULT_MAX_EDITS, DEFAULT_TRANSPOSITIONS, DEFAULT_NON_FUZZY_PREFIX, DEFAULT_MIN_FUZZY_LENGTH, DEFAULT_UNICODE_AWARE); } diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java index 21b5162e768..76dd8a416f5 100644 --- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java +++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java @@ -254,7 +254,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { int options = 0; Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, options, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, options, 256, -1, true); suggester.build(new InputArrayIterator(keys)); // TODO: would be nice if "ab " would allow the test to // pass, and more generally if the analyzer can know @@ -460,7 +460,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { Analyzer a = getUnusualAnalyzer(); int options = AnalyzingSuggester.EXACT_FIRST | AnalyzingSuggester.PRESERVE_SEP; - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, options, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, options, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("x y", 1), new Input("x y z", 3), @@ -499,7 +499,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { public void testNonExactFirst() throws Exception { Analyzer a = getUnusualAnalyzer(); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("x y", 1), @@ -753,7 +753,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { Analyzer a = new MockTokenEatingAnalyzer(numStopChars, preserveHoles); AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, - preserveSep ? AnalyzingSuggester.PRESERVE_SEP : 0, 256, -1, false); + preserveSep ? AnalyzingSuggester.PRESERVE_SEP : 0, 256, -1, true); if (doPayloads) { suggester.build(new InputArrayIterator(shuffle(payloadKeys))); } else { @@ -874,7 +874,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { public void testMaxSurfaceFormsPerAnalyzedForm() throws Exception { Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 2, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 2, -1, true); suggester.build(new InputArrayIterator(shuffle(new Input("a", 40), new Input("a ", 50), new Input(" a", 60)))); @@ -888,7 +888,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { public void testQueueExhaustion() throws Exception { Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.EXACT_FIRST, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.EXACT_FIRST, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("a", 2), @@ -904,7 +904,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.EXACT_FIRST, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.EXACT_FIRST, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("a", 5), @@ -969,7 +969,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { } }; - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, true); suggester.build(new InputArrayIterator(shuffle( new Input("hambone", 6), @@ -1038,7 +1038,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { } }; - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("a", 6), @@ -1111,7 +1111,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { } }; - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("a a", 50), @@ -1121,7 +1121,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { public void testDupSurfaceFormsMissingResults3() throws Exception { Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("a a", 7), new Input("a a", 7), @@ -1134,7 +1134,7 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { public void testEndingSpace() throws Exception { Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("i love lucy", 7), new Input("isla de muerta", 8), @@ -1167,14 +1167,14 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { } }; - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, 1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, 1, true); suggester.build(new InputArrayIterator(new Input[] {new Input("a", 1)})); assertEquals("[a/1]", suggester.lookup("a", false, 1).toString()); } public void testIllegalLookupArgument() throws Exception { Analyzer a = new MockAnalyzer(random()); - AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, false); + AnalyzingSuggester suggester = new AnalyzingSuggester(a, a, 0, 256, -1, true); suggester.build(new InputArrayIterator(new Input[] { new Input("а где Люси?", 7), })); diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java index f2239e29122..40aa96e2c7f 100644 --- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java +++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/FuzzySuggesterTest.java @@ -61,7 +61,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { } keys.add(new Input("foo bar boo far", 12)); MockAnalyzer analyzer = new MockAnalyzer(random(), MockTokenizer.KEYWORD, false); - FuzzySuggester suggester = new FuzzySuggester(analyzer, analyzer, FuzzySuggester.EXACT_FIRST | FuzzySuggester.PRESERVE_SEP, 256, -1, false, FuzzySuggester.DEFAULT_MAX_EDITS, FuzzySuggester.DEFAULT_TRANSPOSITIONS, + FuzzySuggester suggester = new FuzzySuggester(analyzer, analyzer, FuzzySuggester.EXACT_FIRST | FuzzySuggester.PRESERVE_SEP, 256, -1, true, FuzzySuggester.DEFAULT_MAX_EDITS, FuzzySuggester.DEFAULT_TRANSPOSITIONS, 0, FuzzySuggester.DEFAULT_MIN_FUZZY_LENGTH, FuzzySuggester.DEFAULT_UNICODE_AWARE); suggester.build(new InputArrayIterator(keys)); int numIters = atLeast(10); @@ -82,7 +82,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { } keys.add(new Input("фуу бар буу фар", 12)); MockAnalyzer analyzer = new MockAnalyzer(random(), MockTokenizer.KEYWORD, false); - FuzzySuggester suggester = new FuzzySuggester(analyzer, analyzer, FuzzySuggester.EXACT_FIRST | FuzzySuggester.PRESERVE_SEP, 256, -1, false, FuzzySuggester.DEFAULT_MAX_EDITS, FuzzySuggester.DEFAULT_TRANSPOSITIONS, + FuzzySuggester suggester = new FuzzySuggester(analyzer, analyzer, FuzzySuggester.EXACT_FIRST | FuzzySuggester.PRESERVE_SEP, 256, -1, true, FuzzySuggester.DEFAULT_MAX_EDITS, FuzzySuggester.DEFAULT_TRANSPOSITIONS, 0, FuzzySuggester.DEFAULT_MIN_FUZZY_LENGTH, true); suggester.build(new InputArrayIterator(keys)); int numIters = atLeast(10); @@ -208,7 +208,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { int options = 0; Analyzer a = new MockAnalyzer(random()); - FuzzySuggester suggester = new FuzzySuggester(a, a, options, 256, -1, false, 1, true, 1, 3, false); + FuzzySuggester suggester = new FuzzySuggester(a, a, options, 256, -1, true, 1, true, 1, 3, false); suggester.build(new InputArrayIterator(keys)); // TODO: would be nice if "ab " would allow the test to // pass, and more generally if the analyzer can know @@ -417,7 +417,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { public void testExactFirst() throws Exception { Analyzer a = getUnusualAnalyzer(); - FuzzySuggester suggester = new FuzzySuggester(a, a, AnalyzingSuggester.EXACT_FIRST | AnalyzingSuggester.PRESERVE_SEP, 256, -1, false, 1, true, 1, 3, false); + FuzzySuggester suggester = new FuzzySuggester(a, a, AnalyzingSuggester.EXACT_FIRST | AnalyzingSuggester.PRESERVE_SEP, 256, -1, true, 1, true, 1, 3, false); suggester.build(new InputArrayIterator(new Input[] { new Input("x y", 1), new Input("x y z", 3), @@ -456,7 +456,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { public void testNonExactFirst() throws Exception { Analyzer a = getUnusualAnalyzer(); - FuzzySuggester suggester = new FuzzySuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, false, 1, true, 1, 3, false); + FuzzySuggester suggester = new FuzzySuggester(a, a, AnalyzingSuggester.PRESERVE_SEP, 256, -1, true, 1, true, 1, 3, false); suggester.build(new InputArrayIterator(new Input[] { new Input("x y", 1), @@ -683,7 +683,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { Analyzer a = new MockTokenEatingAnalyzer(numStopChars, preserveHoles); FuzzySuggester suggester = new FuzzySuggester(a, a, - preserveSep ? AnalyzingSuggester.PRESERVE_SEP : 0, 256, -1, false, 1, false, 1, 3, unicodeAware); + preserveSep ? AnalyzingSuggester.PRESERVE_SEP : 0, 256, -1, true, 1, false, 1, 3, unicodeAware); suggester.build(new InputArrayIterator(keys)); for (String prefix : allPrefixes) { @@ -823,7 +823,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { public void testMaxSurfaceFormsPerAnalyzedForm() throws Exception { Analyzer a = new MockAnalyzer(random()); - FuzzySuggester suggester = new FuzzySuggester(a, a, 0, 2, -1, false, 1, true, 1, 3, false); + FuzzySuggester suggester = new FuzzySuggester(a, a, 0, 2, -1, true, 1, true, 1, 3, false); List keys = Arrays.asList(new Input[] { new Input("a", 40), @@ -844,7 +844,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { public void testEditSeps() throws Exception { Analyzer a = new MockAnalyzer(random()); - FuzzySuggester suggester = new FuzzySuggester(a, a, FuzzySuggester.PRESERVE_SEP, 2, -1, false, 2, true, 1, 3, false); + FuzzySuggester suggester = new FuzzySuggester(a, a, FuzzySuggester.PRESERVE_SEP, 2, -1, true, 2, true, 1, 3, false); List keys = Arrays.asList(new Input[] { new Input("foo bar", 40), @@ -958,7 +958,7 @@ public class FuzzySuggesterTest extends LuceneTestCase { boolean transpositions = random().nextBoolean(); // TODO: test graph analyzers // TODO: test exactFirst / preserveSep permutations - FuzzySuggester suggest = new FuzzySuggester(a, a, 0, 256, -1, false, maxEdits, transpositions, prefixLen, prefixLen, false); + FuzzySuggester suggest = new FuzzySuggester(a, a, 0, 256, -1, true, maxEdits, transpositions, prefixLen, prefixLen, false); if (VERBOSE) { System.out.println("TEST: maxEdits=" + maxEdits + " prefixLen=" + prefixLen + " transpositions=" + transpositions + " num=" + NUM);