Free NHibernate + Lucene Search (NHibernate.Search)

I am using Fluent NHibernate and I would like to implement NHibernate.Search with Lucene, but I cannot find examples of how to do this with Fluent NHibernate. There seem to be two steps. (According to Castle )

  • Set the Hibernate properties in the configuration:

    • hibernate.search.default.directory_provider
    • hibernate.search.default.indexBase
    • hibernate.search.analyzer
  • Initializing Event Listeners for Indexing Stored Objects

    • 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 original Fluent NHibernate configuration, but I cannot find where the event listeners are configured.

+3
source share
2 answers

If you use the Fluent Configuration API , you just need to use the method ExposeConfigurationto access the NHibernate instance configuration.

Fluently.Configure()
  .Database(...)
  .Mappings(...)
  .ExposeConfiguration(cfg =>
  {
    cfg.SetListener(...);
    cfg.SetListener(...);
  })
  .BuildSessionFactory();
+5
source

I am working on the Fluent API for Lucene , which eliminates the need for attributes and works well with FNH

Its still very pre-alpha, greetings are welcome!

+1
source

Source: https://habr.com/ru/post/1703236/


All Articles