Can I use the same instance of IndexSearcher in Lu

2019-06-24 11:59发布

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?

3条回答
Anthone
2楼-- · 2019-06-24 12:23

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:

http://ifdefined.com/blog/post/Full-Text-Search-in-ASPNET-using-LuceneNET.aspx

查看更多
做个烂人
3楼-- · 2019-06-24 12:26

Yes.Very much.
Even indexing is!

查看更多
【Aperson】
4楼-- · 2019-06-24 12:31

You can index and search concurrently, but the changes you make to the index will not be visible to the searcher till you re-create the searcher. Searcher will have the snapshot of the index when you created the searcher object.

查看更多
登录 后发表回答