在 Lucene.Net 中使用多个数据库设置
你好 我正在使用 Lucene.Net 和 NHibernate.Search 为 Web 应用程序开发搜索功能。该应用程序被许多公司使用,但作为单一服务运行,为不同的公司使用不同的数据库。因此,我需要为每个数据库提供一个索引目录,而不是为整个应用程序提供一个目录。 Lucene.Net 有没有办法实现这一点?
我还考虑过将每个公司的索引存储在各自的数据库中,但尚未找到任何令人满意的组件。我已经阅读了有关 Java 的 Compass 和 JdbcDirectory,但我需要一些用于 C# 或 NHibernate 的内容。有谁知道是否有 JdbcDirectory 的端口或 C# 的类似端口?
Hi
I am developing a search function for an web application with Lucene.Net and NHibernate.Search. The application is used by a lots of companies but is runned as a single service, using different databases for different companies. Therefore I would need an index directory for each database rather than one directory for the entire application. Is there a way of achieve this in Lucene.Net?
I have also considering storing the indexes for each company in there respecitive database but havent found any satisfying compontents for this. I have read about Compass and JdbcDirectory for Java but I need something for C# or NHibernate. Does anyone know if there is a port of JdbcDirectory or something simular for C#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,看起来您无法使用普通的 nhibernate.search 在会话工厂级别更改任何内容。您可能需要单独的配置实例,或者尝试一些类似于 Fluent NHibernate Search< /a> 减轻疼痛。
从项目的 wiki 将其拼凑在一起,您似乎可以执行类似的操作来启动指向不同数据库/索引目录的单独会话工厂:
“IndexBase”属性和连接是您需要为每个客户定义的部分。一旦设置了会话工厂,您就可以使用当前使用的任何策略来解决它们。
希望有帮助
Hmm, it looks like you can't change anything at the session factory level using normal nhibernate.search. You may need separate instances of a configuration, or maybe try something along the lines of Fluent NHibernate Search to ease the pain.
Piecing it together from the project's wiki it appears you could do something like this to spin up separate session factories pointing to different databases / index directories:
The "IndexBase" property and the connection are the parts you'll need to define per customer. Once you get the session factories set up you could resolve them using whatever strategy you use currently.
Hope it helps