lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kris...@apache.org
Subject [20/35] lucene-solr:jira/solr-8593: LUCENE-7670: AnalyzingInfixSuggester should not immediately open an IndexWriter over an already-built index
Date Wed, 01 Feb 2017 17:00:48 GMT
LUCENE-7670: AnalyzingInfixSuggester should not immediately open an IndexWriter over an already-built
index


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

Branch: refs/heads/jira/solr-8593
Commit: c1fe88b7c6fa861d5101f9702a7832d29b8032ee
Parents: 71abe13
Author: Steve Rowe <sarowe@apache.org>
Authored: Tue Jan 31 01:06:43 2017 -0500
Committer: Steve Rowe <sarowe@apache.org>
Committed: Tue Jan 31 01:13:11 2017 -0500

----------------------------------------------------------------------
 .../suggest/analyzing/AnalyzingInfixSuggester.java     |  4 +---
 .../suggest/analyzing/AnalyzingInfixSuggesterTest.java | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c1fe88b7/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
index 81880d4..0ca81c7 100644
--- a/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
+++ b/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
@@ -249,9 +249,7 @@ public class AnalyzingInfixSuggester extends Lookup implements Closeable
{
 
     if (DirectoryReader.indexExists(dir)) {
       // Already built; open it:
-      writer = new IndexWriter(dir,
-                               getIndexWriterConfig(getGramAnalyzer(), IndexWriterConfig.OpenMode.APPEND));
-      searcherMgr = new SearcherManager(writer, null);
+      searcherMgr = new SearcherManager(dir, null);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/c1fe88b7/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
----------------------------------------------------------------------
diff --git a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
index fc5e2b7..478358b 100644
--- a/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
+++ b/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggesterTest.java
@@ -1360,7 +1360,8 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
     // * SearcherManager's IndexWriter reference should be closed 
     //   (as evidenced by maybeRefreshBlocking() throwing AlreadyClosedException)
     Analyzer a = new MockAnalyzer(random(), MockTokenizer.WHITESPACE, false);
-    MyAnalyzingInfixSuggester suggester = new MyAnalyzingInfixSuggester(newDirectory(), a,
a, 3, false,
+    Path tempDir = createTempDir("analyzingInfixContext");
+    final MyAnalyzingInfixSuggester suggester = new MyAnalyzingInfixSuggester(newFSDirectory(tempDir),
a, a, 3, false,
         AnalyzingInfixSuggester.DEFAULT_ALL_TERMS_REQUIRED, AnalyzingInfixSuggester.DEFAULT_HIGHLIGHT,
true);
     suggester.build(new InputArrayIterator(sharedInputs));
     assertNull(suggester.getIndexWriter());
@@ -1368,6 +1369,16 @@ public class AnalyzingInfixSuggesterTest extends LuceneTestCase {
     expectThrows(AlreadyClosedException.class, () -> suggester.getSearcherManager().maybeRefreshBlocking());
     
     suggester.close();
+
+    // After instantiating from an already-built suggester dir:
+    // * The IndexWriter should be null
+    // * The SearcherManager should be non-null
+    final MyAnalyzingInfixSuggester suggester2 = new MyAnalyzingInfixSuggester(newFSDirectory(tempDir),
a, a, 3, false,
+        AnalyzingInfixSuggester.DEFAULT_ALL_TERMS_REQUIRED, AnalyzingInfixSuggester.DEFAULT_HIGHLIGHT,
true);
+    assertNull(suggester2.getIndexWriter());
+    assertNotNull(suggester2.getSearcherManager());
+
+    suggester2.close();
     a.close();
   }
   


Mime
View raw message