[
http://issues.apache.org/jira/browse/LUCENE-632?page=comments#action_12423714 ]
Otis Gospodnetic commented on LUCENE-632:
-----------------------------------------
I put the new IndexSearcher call to the setSpellIndex(Dictionary) method, which
is called from the SpellChecker constructor. I did that the other day, so
maybe I broke something, although everything worked for me and I didn't get any
NPEs.
I use code that looks like this:
public void createDictionary(String field, Directory sourceIndex, Directory
spellIndex) throws IOException {
IndexReader reader = null;
try {
reader = IndexReader.open(sourceIndex);
Dictionary dictionary = new LuceneDictionary(reader, field);
SpellChecker spellChecker = new SpellChecker(spellIndex);
spellChecker.indexDictionary(dictionary);
} finally {
if (reader != null) {
reader.close();
}
}
}
public static void main(String[] args) throws IOException {
if (args.length < 3) {
System.err.println("Usage: java " + SpellerIndexer.class
+ " <source field> <source index> <spell index>");
System.exit(1);
}
System.out.print("\nCreating spell checker index in " + args[2] + " ...
");
SpellerIndexer indexer = new SpellerIndexer();
Directory sourceIndex = FSDirectory.getDirectory(args[1], false);
Directory spellIndex = FSDirectory.getDirectory(args[2],
IndexReader.indexExists(args[2]));
indexer.createDictionary(args[0], sourceIndex, spellIndex);
System.out.println("done\n");
}
Karsten:
If you still think there is a bug in the SVN version, please comment here.
I can apply the lazy searcher patch from Karl (see Karl, you don't always get
ignored! :)), but I'm not sure that it will make a difference. If you apply it
and it makes a difference for you, please follow up here.
> The creation of a spell index from a LuceneDictionary via
> SpellChecker.indexDictionary (Dictionary dict) fails starting with 1.9.1 (up
> to current svn version)
> --------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Key: LUCENE-632
> URL: http://issues.apache.org/jira/browse/LUCENE-632
> Project: Lucene - Java
> Issue Type: Bug
> Components: Other
> Affects Versions: 2.0.0, 1.9
> Reporter: Karsten Dello
> Priority: Minor
> Attachments: lazy_searcher.diff
>
>
> Two different errors in 1.9.1/2.0.0 and current svn version.
> 1.9.1/2.0.0:
> at the end of indexDictionary (Dictionary dict)
> the IndexReader-instance reader is closed.
> This causes a NullpointerException because reader has not been initialized
> before (neither in that method nor in the constructor).
> Uncommenting this line (reader.close()) seems to resolve that issue.
> current svn:
> the constructor tries to create an IndexSearcher-instance for the specified
> path;
> as there is no index in that path - it is not created yet - an exception is
> thrown.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]