LUCENE-7914: Fix TestSuggestField#testRealisticKeys: trim big titles to make sure that they can pass the max recursion level in Operations#topsortState.

This commit is contained in:
Jim Ferenczi 2017-08-08 14:25:23 +02:00
parent a4db6ce3e6
commit 2a8930cf83
1 changed files with 5 additions and 3 deletions

View File

@ -719,13 +719,15 @@ public class TestSuggestField extends LuceneTestCase {
for (int i = 0; i < num; i++) {
Document document = lineFileDocs.nextDoc();
String title = document.getField("title").stringValue();
int maxLen = Math.min(title.length(), 500);
String prefix = title.substring(0, maxLen);
int weight = random().nextInt(Integer.MAX_VALUE);
Integer prevWeight = mappings.get(title);
Integer prevWeight = mappings.get(prefix);
if (prevWeight == null || prevWeight < weight) {
mappings.put(title, weight);
mappings.put(prefix, weight);
}
Document doc = new Document();
doc.add(new SuggestField("suggest_field", title, weight));
doc.add(new SuggestField("suggest_field", prefix, weight));
iw.addDocument(doc);
if (rarely()) {