Hi, I am new to Lucene. Hope the question is not too naive.
>From Lucene FAQ, i know that IndexSearcher instance shall be shared by threads, rather than opening one for each thread. However, after index rebuild, we need to create a new IndexSearcher instance, and call close() on the old indexSearcher instance. Here is the pseudo code: public class SearchEngine { private IndexSearcher iSearcher = null; public void setIndexSearcher(IndexSearcher searcher) { this.iSearcher.close(); this.iSearcher = searcher; } public void search() { iSearcher search(); } } As you can see, after index rebuild, one thread wants to call SearchEngine.setIndexSearcher to instantiate a new IndexSearcher. Before that, it also needs to clean up the resource of the old IndexSearcher by calling close(). At the same time, another thread is in the middle of search of the old indexSearcher object. That is why I am concerned whether I might get some weird exception by calling searcher.close() and searcher.search() concurrently by different threads. Will that be a problem? Or lucene takes care of the synchronization between close() and search(), or that does not need any synchronization at all? Bottom line is that I don't want to do synchronization between close() and search(). Or is there more elegant way of passing a new IndexSearcher after index rebuild without any resource leak? -- View this message in context: http://www.nabble.com/IndexSearcher-close%28%29-and-search%28%29-called-concurrently-by-different-threads--tp25655337p25655337.html Sent from the Lucene - Java Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org For additional commands, e-mail: java-user-h...@lucene.apache.org