我可以同时使用多个线程在Lucene.Net中使用相同的IndexSearcher实例吗?

时间:2021-03-21 03:04:32

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

我希望能够在Lucene.Net中同时搜索多个客户端和索引

Is it possible and thread safe?

有可能和线程安全吗?

Can the same instance of IndexSearcher be shared across threads?

可以跨线程共享同一个IndexSearcher实例吗?

3 个解决方案

#1


The index search CAN and SHOULD be shared across threads.

索引搜索CAN和应该在线程之间共享。

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

#2


Yes.Very much.
Even indexing is!

是的。很多。索引就是!

#3


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.

您可以同时进行索引和搜索,但在重新创建搜索器之前,搜索器将无法看到您对索引所做的更改。在创建搜索器对象时,Searcher将获得索引的快照。

#1


The index search CAN and SHOULD be shared across threads.

索引搜索CAN和应该在线程之间共享。

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

#2


Yes.Very much.
Even indexing is!

是的。很多。索引就是!

#3


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.

您可以同时进行索引和搜索,但在重新创建搜索器之前,搜索器将无法看到您对索引所做的更改。在创建搜索器对象时,Searcher将获得索引的快照。