You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Matthew York <ma...@kcsplc.com> on 2006/08/18 08:46:38 UTC
SpellChecker
Hi, I'm having issues creating a SpellChecker index.
I am running JRE 1.5.0_06, and have the following in my classpath - lucene-core-2.0.0.jar & lucene-spellchecker-2.0.0.jar.
When I run the code below I get the following exception and a 1KB segments file in the spellIndexDirectoryPath:
Exception in thread "main" java.lang.NullPointerException
at org.apache.lucene.search.spell.SpellChecker.indexDictionary(SpellChecker.java:298)
at com.kcs.pi.Search.main(Search.java:49)
Any help would be appreciated. Thanks
IndexWriter writer = new IndexWriter(originalIndexDirectoryPath, new StandardAnalyzer(), true);
Document doc = new Document();
doc.add(new Field("contents", "seventy", Field.Store.YES, Field.Index.TOKENIZED));
writer.addDocument(doc);
writer.optimize();
writer.close();
FSDirectory originalIndexDirectory = FSDirectory.getDirectory(originalIndexDirectoryPath, false);
FSDirectory spellIndexDirectory = FSDirectory.getDirectory(spellIndexDirectoryPath, true);
IndexReader indexReader = IndexReader.open(originalIndexDirectory);
Dictionary dictionary = new LuceneDictionary(indexReader,"contents");
SpellChecker spellChecker = new SpellChecker(spellIndexDirectory);
spellChecker.indexDictionary(dictionary);
indexReader.close();
---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org