.net – use the same instance of IndexSearcher in Lucene.Net by multiple threads concurrently

lucenelucene.net

I want to be able to search by multiple clients and index at the same time in Lucene.Net

Is it possible and thread safe?

Can the same instance of IndexSearcher be shared across threads?

Best Answer

The index search CAN and SHOULD be shared across threads.

The trick is deciding when to refresh your searcher with a new snapshot of the index.

I wrote an article showing how I coded sharing a searcher across threads while at the same time making sure that the searcher was always using an up-to-date index.

I'm not saying my solution is the best for everybody - I don't think it would be good for a website with a huge number of searches going on - but it's working fine for my low volume application.

Here's the article:

https://web.archive.org/web/20090612224537/https://ifdefined.com/blog/post/Full-Text-Search-in-ASPNET-using-LuceneNET.aspx

Related Topic