IncRef/DecRef is the best way to handle this: you have to ensure the reader is not closed until 1) your app wants to close it (eg a reopen has completed), and 2) every query in-flight, that had been using the reader, has completed.
Lucene in Action 2 (NOTE: I'm a coauthor) has a class (SearcherManager) that handles these details for you. It also handles reopening (with optional warming) the reader, including "normal" readers and near real-time readers. You can download the book's source code from http://manning.com/hatcher3/. Mike On Sun, Feb 7, 2010 at 2:14 AM, Dima Volsky <vol...@gmail.com> wrote: > Hi, > > > I'm trying run a scenario in which I have one index writer and several > readers. I use the MultiReader for searching on several indexes. > The application is multi-threaded so the MultiReader is accessed from > several threads sequentialy. > > > In some stage during the run I get AlreadyClosedException: this IndexReader > is closed > > > I wanted an advise about best practices running such a scenario. > > Should I use the IncRef and the DecRef for managing the MultiReader > references? > > I would be grateful if I could get some advice on this. > > Thanks, > > Dmitri > --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org