From 6b3ea4d0c24adad9a270e43a3b5e07aac8317bee Mon Sep 17 00:00:00 2001 From: Jim Ferenczi Date: Mon, 7 Aug 2017 09:12:31 +0200 Subject: [PATCH] LUCENE-7914: AnalyzingSuggesterTest#testRandomRealisticKeys: trim big titles to make sure that they can pass the max recursion level in Operations#topsortState. --- .../search/suggest/analyzing/AnalyzingSuggesterTest.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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 06d44b9a8bf..67ff056eb58 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 @@ -176,9 +176,11 @@ public class AnalyzingSuggesterTest extends LuceneTestCase { Document nextDoc = lineFile.nextDoc(); String title = nextDoc.getField("title").stringValue(); int randomWeight = random().nextInt(100); - keys.add(new Input(title, randomWeight)); - if (!mapping.containsKey(title) || mapping.get(title) < randomWeight) { - mapping.put(title, Long.valueOf(randomWeight)); + int maxLen = Math.min(title.length(), 500); + String prefix = title.substring(0, maxLen); + keys.add(new Input(prefix, randomWeight)); + if (!mapping.containsKey(prefix) || mapping.get(prefix) < randomWeight) { + mapping.put(prefix, Long.valueOf(randomWeight)); } } Analyzer indexAnalyzer = new MockAnalyzer(random());