Hi,
I'm starting to work on an app to list all of the terms in the "path" field.
I'm including the beginning of my code below.
When I run this, pointing it to a directory named "index" containing the Lucene
indexes, I am getting a java.io.IOException.
Here's the output when I run:
Index in directory :[C:\lucene-devel\lucene-devel\index] was opened
successfully!
About to drop into while()...
** ERROR **: Exception while stepping through index: [java.io.IOException: The
handle is invalid]
and here's the code:
import java.io.IOException;
import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermEnum;
public class ReadIndex {
public static void main(String[] args) {
IndexReader reader = null;
TermEnum termsEnumerator = null;
Term currentTerm = null;
try {
reader = IndexReader.open(args[0]);
Term term = new Term("path", "");
termsEnumerator = reader.terms(term);
} catch (IOException e) {
System.out.println("** ERROR **: Exception when opened
IndexReader: [" + e + "]");
} finally {
try { reader.close(); } catch (IOException e) { /* suck
it up */ }
}
System.out.println("Index in directory :[" + args[0] + "] was
opened successfully!");
try {
System.out.println("About to drop into while()...");
while (termsEnumerator.next()) {
System.out.println("About to get
terms.Enumerator.term()...");
currentTerm = termsEnumerator.term();
System.out.println("Term = [" +
currentTerm.text() + "]");
}
termsEnumerator.close();
} catch (Exception e) {
System.out.println("** ERROR **: Exception while
stepping through index: [" + e + "]");
}
} // end main()
} // end CLASS ReadIndex
Can anyone tell me what might be causing that exception?
Thanks,
Jim
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]