lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jim...@apache.org
Subject lucene-solr:branch_7x: LUCENE-7914: Fix TestSuggestField#testRealisticKeys: trim big titles to make sure that they can pass the max recursion level in Operations#topsortState.
Date Tue, 08 Aug 2017 12:26:24 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 95af49e58 -> 806a48557


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


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/806a4855
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/806a4855
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/806a4855

Branch: refs/heads/branch_7x
Commit: 806a485576d20bb39781d1bd73cdc78f690c40e9
Parents: 95af49e
Author: Jim Ferenczi <jimczi@apache.org>
Authored: Tue Aug 8 14:25:23 2017 +0200
Committer: Jim Ferenczi <jimczi@apache.org>
Committed: Tue Aug 8 14:26:12 2017 +0200

----------------------------------------------------------------------
 .../lucene/search/suggest/document/TestSuggestField.java     | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/806a4855/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestSuggestField.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestSuggestField.java
b/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestSuggestField.java
index a797ca5..a6659e0 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestSuggestField.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/document/TestSuggestField.java
@@ -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()) {


Mime
View raw message