Skip to main content

Posts

Showing posts with the label lucene

Is it good practice to keep a Lucene IndexWriter & IndexSearcher open for the lifetime of an app

It states in the Lucene documentation that it is fastest to use one instance of an IndexWriter and IndexSearcher across an application. At the moment I have a static instance of IndexWriter open at all times, and a static instance of IndexSearcher that is kept open at all times but rebuilt when if the IndexWriter performs any CRUD operations on the index. I have implemented a Dispose method on my index management class that closes both the IndexWriter and IndexSearcher when the application ends (however it is a web app so this is potentially months of running without being called). Does that sound like reasonable way to go about doing things? And also does using static instances present problems with multi-threading..? I.e. should I be locking my writer and searcher when in use?