mirror of https://github.com/apache/lucene.git
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:
parent
a4db6ce3e6
commit
2a8930cf83
|
@ -719,13 +719,15 @@ public class TestSuggestField extends LuceneTestCase {
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
Document document = lineFileDocs.nextDoc();
|
Document document = lineFileDocs.nextDoc();
|
||||||
String title = document.getField("title").stringValue();
|
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);
|
int weight = random().nextInt(Integer.MAX_VALUE);
|
||||||
Integer prevWeight = mappings.get(title);
|
Integer prevWeight = mappings.get(prefix);
|
||||||
if (prevWeight == null || prevWeight < weight) {
|
if (prevWeight == null || prevWeight < weight) {
|
||||||
mappings.put(title, weight);
|
mappings.put(prefix, weight);
|
||||||
}
|
}
|
||||||
Document doc = new Document();
|
Document doc = new Document();
|
||||||
doc.add(new SuggestField("suggest_field", title, weight));
|
doc.add(new SuggestField("suggest_field", prefix, weight));
|
||||||
iw.addDocument(doc);
|
iw.addDocument(doc);
|
||||||
|
|
||||||
if (rarely()) {
|
if (rarely()) {
|
||||||
|
|
Loading…
Reference in New Issue