在Lucene.Net中使用几种数据库设置 [英] Using several database setups with Lucene.Net

查看:81
本文介绍了在Lucene.Net中使用几种数据库设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我正在使用Lucene.Net和NHibernate.Search为Web应用程序开发搜索功能.该应用程序被许多公司使用,但是作为一个服务运行,并为不同的公司使用不同的数据库.因此,对于每个数据库,我将需要一个索引目录,而对于整个应用程序,则将需要一个目录.在Lucene.Net中有实现此目的的方法吗?

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?

我也考虑过将每个公司的索引存储在相应的数据库中,但是还没有找到令人满意的组件.我已经阅读了有关Java的Compass和JdbcDirectory的信息,但是我需要一些用于C#或NHibernate的东西.有人知道JdbcDirectory的端口或C#的类似端口吗?

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#?

推荐答案

嗯,看来您无法使用正常的nhibernate.search在会话工厂级别更改任何内容.您可能需要单独的配置实例,或者尝试使用 Fluent NHibernate Search 减轻疼痛.

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.

从项目的Wiki中将其拼接在一起,看来您可以执行以下操作来启动指向不同数据库/索引目录的单独的会话工厂:

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:

Fluently.Configure()
    .Database(SQLiteConfiguration.Standard.InMemory())
    .Search(s => s.DefaultAnalyzer().Standard()
                             .DirectoryProvider().FSDirectory()
                             .IndexBase("~/Index")
                             .IndexingStrategy().Event()
                             .MappingClass<LibrarySearchMapping>())
    .BuildConfiguration()
    .BuildSessionFactory();

"IndexBase"属性和连接是您需要为每个客户定义的部分.一旦建立了会话工厂,就可以使用当前使用的任何策略来解决它们.

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.

希望有帮助

这篇关于在Lucene.Net中使用几种数据库设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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