lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael McCandless <>
Subject Re: How to safely close Index objects?
Date Wed, 11 Nov 2009 09:56:29 GMT
On Wed, Nov 11, 2009 at 12:13 AM, Jacob Rhoden <> wrote:

> Given a class with two static variables, is the following safe? ie If I call
> "close" while something else is using the objects, do the objects simply
> hold a flag saying they need to be destroyed once the objects are finished
> being used, or do they not track if anything is currently using the object
> and simply blow up if I try to close them?

You shouldn't close your IndexReader/IndexSearcher unless all searches
are done using them, otherwise you'll hit exceptions.

Also, if you don't separately use the IndexReader, you can just
open/close the IndexSearcher.

However, it's better to use IndexReader's reopen method, which only
opens the new segments created since the last time the reader was

> How does one get the early edition of the lucene book? I couldn't work out
> how from the website. I am assuming I am missing something obvious (:

You can get the book here (NOTE: I'm
one of the authors!).

Chapter 11 in the book has a class called SearcherManager, that
handles the details of reopen/closing the IndexReader while queries
are still in flight, that might be useful here.


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

View raw message