我可以通过多个线程同时使用Lucene.Net中的IndexSearcher的同一实例吗? [英] Can I use the same instance of IndexSearcher in Lucene.Net by multiple threads concurrently?

查看:84
本文介绍了我可以通过多个线程同时使用Lucene.Net中的IndexSearcher的同一实例吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望能够同时在Lucene.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?

是否可以在线程之间共享IndexSearcher的同一实例?

Can the same instance of IndexSearcher be shared across threads?

推荐答案

索引搜索可以并且应该在线程之间共享.

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.

这是文章:

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

这篇关于我可以通过多个线程同时使用Lucene.Net中的IndexSearcher的同一实例吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆