我使用nhibernate/ActiveRecord項目進行了nHibernate搜索。Nhibernate搜索更新後監聽器
我想讓我的更新後的偵聽器正常工作,但似乎每次我更新一個裝飾有[Indexed]屬性的對象時,它會導致nhibernate.search創建一個新的IndexReader( Workspace.cs GetIndexReader方法),大約需要30秒!
任何想法爲什麼nhibernate.search是這樣做的?
繼承人我的配置
<configSections>
<section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/>
</configSections>
<activerecord isWeb="true">
<config>
<add key="connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<add key="dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<add key="connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<add key="connection.connection_string" value="Data Source=***;user id=****;password=****;Initial Catalog=*****" />
<add key="hibernate.search.default.directory_provider" value="NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search" />
<add key="hibernate.search.default.indexBase" value="C:\LuceneIndex" />
<add key="hibernate.search.analyzer" value="Lucene.Net.Analysis.Standard.StandardAnalyzer, Lucene.Net"/>
<add key="hibernate.search.indexing_strategy" value="event" />
<add key="hibernate.search.reader.strategy" value="shared" />
</config>
</activerecord>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="proxyfactory.factory_class"> NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu </property>
<event type="delete">
<listener class="SoftDeleteListener, Mydll"/>
</event>
<event type="post-update">
<listener class="NHibernate.Search.Event.FullTextIndexEventListener, NHibernate.Search" />
</event>
<event type="post-insert">
<listener class="NHibernate.Search.Event.FullTextIndexEventListener, NHibernate.Search" />
</event>
<event type="post-delete">
<listener class="NHibernate.Search.Event.FullTextIndexEventListener, NHibernate.Search" />
</event>
</session-factory>
</hibernate-configuration>
我programitcally加入我的事件監聽器(更新後現在只)
NHibernate.Cfg.Configuration configuration = ActiveRecordMediator.GetSessionFactoryHolder().GetConfiguration(typeof(ActiveRecordBase));
configuration.SetListeners(ListenerType.PostUpdate, new IPostUpdateEventListener[] { new FullTextIndexEventListener() });