You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2016/02/16 23:40:04 UTC

lucene-solr git commit: suppress IW's pending deletes check when creating SpellChecker

Repository: lucene-solr
Updated Branches:
  refs/heads/master 0bba33254 -> 25931d362


suppress IW's pending deletes check when creating SpellChecker


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

Branch: refs/heads/master
Commit: 25931d36248d57e52847feee1a2ecd0be98954b6
Parents: 0bba332
Author: Mike McCandless <mi...@apache.org>
Authored: Tue Feb 16 17:41:05 2016 -0500
Committer: Mike McCandless <mi...@apache.org>
Committed: Tue Feb 16 17:41:05 2016 -0500

----------------------------------------------------------------------
 .../org/apache/solr/spelling/AbstractLuceneSpellChecker.java | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/25931d36/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java b/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
index 941fdae..3d7392a 100644
--- a/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
+++ b/solr/core/src/java/org/apache/solr/spelling/AbstractLuceneSpellChecker.java
@@ -37,6 +37,7 @@ import org.apache.lucene.search.spell.Dictionary;
 import org.apache.lucene.search.spell.LevensteinDistance;
 import org.apache.lucene.search.spell.SpellChecker;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.FilterDirectory;
 import org.apache.lucene.store.FSDirectory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.solr.common.params.ShardParams;
@@ -224,7 +225,12 @@ public abstract class AbstractLuceneSpellChecker extends SolrSpellChecker {
    */
   protected void initIndex() throws IOException {
     if (indexDir != null) {
-      index = FSDirectory.open(new File(indexDir).toPath());
+      // TODO: this is a workaround for SpellChecker repeatedly closing and opening a new IndexWriter while leaving readers open, which on
+      // Windows causes problems because deleted files can't be opened.  It would be better for SpellChecker to hold a single IW instance,
+      // and close it on close, but Solr never seems to close its spell checkers.  Wrapping as FilterDirectory prevents IndexWriter from
+      // catching the pending deletions:
+      index = new FilterDirectory(FSDirectory.open(new File(indexDir).toPath())) {
+      };
     } else {
       index = new RAMDirectory();
     }