流畅的 NHibernate + Lucene 搜索 (NHibernate.Search) [英] Fluent NHibernate + Lucene Search (NHibernate.Search)
问题描述
我正在使用 Fluent NHibernate,我想用 Lucene 实现 NHibernate.Search,但我找不到任何关于如何使用 Fluent NHibernate 来实现的示例.似乎有两个步骤.(根据城堡)
I'm using Fluent NHibernate and I would like to implement NHibernate.Search with Lucene but I can't find any examples on how to do that with Fluent NHibernate. It appears there are two steps. (According to Castle)
在配置中设置 Hibernate 属性:
Set the Hibernate properties in the configuration:
- hibernate.search.default.directory_provider
- hibernate.search.default.indexBase
- hibernate.search.analyzer
初始化事件监听器以索引持久化对象
Initializing the Event Listeners to index persisted objcts
- configuration.SetListener(ListenerType.PostUpdate, new FullTextIndexEventListener());
- configuration.SetListener(ListenerType.PostInsert, new FullTextIndexEventListener());
- configuration.SetListener(ListenerType.PostDelete, new FullTextIndexEventListener());
我知道如何将属性添加到 Fluent NHibernate 源配置,但 我找不到设置事件侦听器的位置.
I figured out how to add properties to the Fluent NHibernate Source Configuration, but I cannot find where the Event Listeners are setup.
推荐答案
如果你使用的是 FluentConfiguration API,那么你只需要使用 ExposeConfiguration
方法来获取 NHibernate Configuration 实例.
If you're using the Fluent Configuration API, then you just need to use the ExposeConfiguration
method to get at the NHibernate Configuration instance.
Fluently.Configure()
.Database(...)
.Mappings(...)
.ExposeConfiguration(cfg =>
{
cfg.SetListener(...);
cfg.SetListener(...);
})
.BuildSessionFactory();
这篇关于流畅的 NHibernate + Lucene 搜索 (NHibernate.Search)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!