Re: Safely closing stale IndexReaders

2010-10-05 Thread Michael McCandless
2010/10/5 Mindaugas Žakšauskas : > The key bit: release(searcher) here calls IndexReader.decRef() which > in turn closes the index when necessary. Ahh yes. > This approach has the same disadvantage of object pooling I have > mentioned in my original email. The "do searching & rendering" phase >

Re: Safely closing stale IndexReaders

2010-10-05 Thread Mindaugas Žakšauskas
Hi, Thanks for your input Mike. As far as I understand, your suggestion is to do something like this: IndexSearcher searcher = searcherManager.get(); try { // do searching & rendering here… } finally { searcherManager.release(searcher) ; } The key bit: release(searcher) here calls IndexRead

Re: Safely closing stale IndexReaders

2010-10-05 Thread Michael McCandless
Check out the SearcherManager class in Lucene in Action 2nd edition's source code. It's free for download at Manning's site (http://manning.com/lucene). NOTE: I am one of the co-authors. I think that class does exactly what you're seeking. It uses reference counts to ensure a reader is closed a