Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr 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.txt
index b23defaf75d..93386dc28a9 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -64,6 +64,9 @@ API Changes
replacement character U+FFFD. This is a change to the index file
format. (Marvin Humphrey via Mike McCandless)
+ 8. LUCENE-852: Let the SpellChecker caller specify IndexWriter mergeFactor
+ and RAM buffer size. (Otis Gospodnetic)
+
Bug fixes
1. LUCENE-1134: Fixed BooleanQuery.rewrite to only optimize a single
diff --git a/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java b/contrib/spellchecker/src/java/org/apache/lucene/search/spell/SpellChecker.java
index 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;