Apache Lucene open-source search software
LUCENE-852: Let the SpellChecker caller specify IndexWriter mergeFactor and RAM buffer size.
Otis Gospodneticce557ee4b379
diff --git a/CHANGES.txt b/CHANGES.txtindex b23defaf75d..93386dc28a9 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -64,6 +64,9 @@ API Changesreplacement character U+FFFD. This is a change to the index fileformat. (Marvin Humphrey via Mike McCandless)+ 8. LUCENE-852: Let the SpellChecker caller specify IndexWriter mergeFactor+ and RAM buffer size. (Otis Gospodnetic)+Bug fixes1. LUCENE-1134: Fixed BooleanQuery.rewrite to only optimize a singlediff --git a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.javaindex 014c5004176..9274b26c2cf 100755--- a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java+++ b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java@@ -303,14 +303,16 @@ public class SpellChecker {}/**- * Index a Dictionary- * @param dict the dictionary to index+ * Indexes the data from the given {@link Dictionary}.+ * @param dict Dictionary to index+ * @param mergeFactor mergeFactor to use when indexing+ * @param ramMB the max amount or memory in MB to use* @throws IOException*/- public void indexDictionary(Dictionary dict) throws IOException {+ public void indexDictionary(Dictionary dict, int mergeFactor, int ramMB) throws IOException {IndexWriter writer = new IndexWriter(spellIndex, true, new WhitespaceAnalyzer());- writer.setMergeFactor(300);- writer.setMaxBufferedDocs(150);+ writer.setMergeFactor(mergeFactor);+ writer.setRAMBufferSizeMB(ramMB);Iterator iter = dict.getWordsIterator();while (iter.hasNext()) {@@ -338,6 +340,15 @@ public class SpellChecker {searcher = new IndexSearcher(this.spellIndex);}+ /**+ * Indexes the data from the given {@link Dictionary}.+ * @param dict the dictionary to index+ * @throws IOException+ */+ public void indexDictionary(Dictionary dict) throws IOException {+ indexDictionary(dict, 300, 10);+ }+private int getMin(int l) {if (l > 5) {return 3;