关于使用 Lucene 进行架构的建议?
我只是想知道我应该如何在应用程序中构建 Lucene 上下文,是否走在正确的轨道上:
- 创建一个将创建编写器实例的单例类。
- 每次需要读取索引时构造一个读取器。
- 检查 reader.IsCurrent() 以确定是否有更新。 3a.如果有更新,请从 IndexWriter 获取读者以使用 NRT。
- 提交有关某个阈值的任何更改并重置读取器。
让我知道我是否走在正确的轨道上。关于如何读写的信息太多,但关于使用 NRT 以及何时正确提交的信息却不够。
I just want to know if I am on the right track with how I should architect my Lucene context in my application:
- Create a singleton class that will create an instance of the writer.
- Construct a reader each time the index needs to be read.
- Check the reader.IsCurrent() to determine if there are updates.
3a. If there are updates get the reader from the IndexWriter to use NRT. - Commit any changes with regards to some threshold and reset the reader.
Let me know if I am on the right track. There is so much information about how to read and write, but not enough about using NRT and when to make commits properly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您基本上走在正确的道路上,但事实上,您可以在所有应用程序中共享阅读器/搜索器的单个实例,而无需构建它。
如果您有多个索引来管理它们,请尝试拥有一个索引读取器/写入器工厂,并且如果您能负担得起,请尝试将读取器和写入器保留在同一个应用程序中,这样您就可以受益于 Lucene.NET 的 NRT 功能。
另外,请查看此 wiki 以获取 NRT 建议:
http://wiki.apache.org/lucene-java/近实时搜索
You are mostly on the right path, but in fact, you can share a single instance of your reader/searcher in all the application without constructing it.
Try to have an index reader/writer factory if you have multiple indexes to manage them and if you can afford it, try to keep in the same application the reader and the writer, so you can benefit of the NRT feature of Lucene.NET.
Also, check this wiki for NRT advices:
http://wiki.apache.org/lucene-java/NearRealtimeSearch
我已经使用几乎相同的架构有一段时间了,我发现它工作得很好。不要在步骤 3a 中从 IndexWriter 获取读取器,而是尝试使用 IndexReader.Reopen()。在第 4 步中,只要 IsCurrent() 为 false,您就可以简单地调用 Reopen()。
I have been using almost the same exact architecture for awhile now, and I have found it to work fine. Instead of getting the reader from IndexWriter in step 3a, try using IndexReader.Reopen(). And in step 4, you can simply call Reopen() whenever IsCurrent() is false.