Olivier Jaquemet wrote:
Thank you very much Volodymyr!
Exactly the perfect answer I needed.
One last question: how do you manage brutal interruption of you
program? Cause as far as I am concerned, if I don't use a finalize
method in which I close opened searchers, if for some reason the jvm
terminates, on next run of my program, lucene throws TimeOut exception
when trying to open lock file, as it was not close properly.
I'm using following code during program startup
try {
if ( !IndexReader.indexExists(indexDirectory)) {
// working index doesn't exist so try to create a dummy index.
IndexWriter iw = new IndexWriter(indexDirectory, new
StandardAnalyzer(), true);
iw.close();
} else {
IndexReader.unlock(FSDirectory.getDirectory(indexDirectory, false));
}
} catch (IOException e) {
// exception
}
but this method should be used if you are running only one instance of
such program (because one program can unlock index locked by another
program for indexing for example)
--
regards,
Volodymyr Bychkoviak
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]