Fluent NHibernate + Lucene Search (NHibernate.Search)

依然范特西╮ 提交于 2019-12-03 05:25:57

问题


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)

  1. Set the Hibernate properties in the configuration:

    • hibernate.search.default.directory_provider
    • hibernate.search.default.indexBase
    • hibernate.search.analyzer
  2. 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());

I figured out how to add properties to the Fluent NHibernate Source Configuration, but I cannot find where the Event Listeners are setup.


回答1:


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();



回答2:


I'm working on a Fluent API for Lucene which removes the need for attributes and integrated nicely with FNH

Its still very pre-alpha, contributions welcome!



来源:https://stackoverflow.com/questions/551101/fluent-nhibernate-lucene-search-nhibernate-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!