mirror of https://github.com/apache/lucene.git
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
This commit is contained in:
parent
b4f7c37bd1
commit
ce557ee4b3
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue