lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Karsten Dello (JIRA)" <>
Subject [jira] Commented: (LUCENE-632) 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)
Date Mon, 24 Jul 2006 19:37:14 GMT
    [ ] 
Karsten Dello commented on LUCENE-632:

Here is the code.
It is copied from

I am pretty sure this code worked with 1.4.3?

package de.kobv.lucene.spellcheck;

import org.apache.lucene.index.IndexReader;

public class SpellCheckIndexer {

	public final static String LUCENEFIELD="AlleFelder";

    public static void main(String [] args) {
    	if (args.length!=2) {
    		System.out.println("usage: java de.kobv.lucene.spellcheck.SpellCheckIndexer <sourceIndexDirectory>
    	String indexDir=args[0];
    	String spellcheckpath=args[1];
    	try {
    	SpellCheckIndexer sci= new SpellCheckIndexer();
    	System.out.println("creating spell check index at "+new java.util.Date(System.currentTimeMillis()));
    	System.out.println("indexDir:"+indexDir+" spellcheckdir:"+spellcheckpath);
    	Directory d1 = FSDirectory.getDirectory(indexDir,false);

    	// make sure the directory exists
    	File f= new File(spellcheckpath);

    	Directory d2= FSDirectory.getDirectory(spellcheckpath,true);

    	System.out.println("finished at"+new java.util.Date(System.currentTimeMillis()));
    	catch(Exception e) {e.printStackTrace(System.out);}

    public void createSpellIndex(String field,
            Directory originalIndexDirectory,
            Directory spellIndexDirectory) throws IOException {

    	System.out.println(""+field+" - "+originalIndexDirectory+" - "+spellIndexDirectory);
        IndexReader indexReader = null;
        try {
            indexReader =;
            System.out.println("Index mit "+indexReader.numDocs()+" docs in "+originalIndexDirectory+"
            Dictionary dictionary = new LuceneDictionary(indexReader, field);
            SpellChecker spellChecker = new SpellChecker(spellIndexDirectory);
        catch (Exception e) {
        finally {
            if (indexReader != null) {


> 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:
>             Project: Lucene - Java
>          Issue Type: Bug
>          Components: Other
>    Affects Versions: 1.9, 2.0.0
>            Reporter: Karsten Dello
>            Priority: Minor
> 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:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message