From ce557ee4b379aba5aab3cdb649d3c7a9896afa9f Mon Sep 17 00:00:00 2001 From: Otis Gospodnetic Date: Thu, 22 May 2008 06:47:36 +0000 Subject: [PATCH] LUCENE-852: Let the SpellChecker caller specify IndexWriter mergeFactor and RAM buffer size. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@659021 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +++ .../lucene/search/spell/SpellChecker.java | 21 ++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) 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;