lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Volodymyr Bychkoviak <>
Subject Re: Renewing IndexSearcher on index change.
Date Tue, 04 Oct 2005 16:20:09 GMT

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);
      } 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)

Volodymyr Bychkoviak

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

View raw message