Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add NHibernate configuration file to use NHibernate.Search?

I try to use NHibernate.Search that I built from trunk and use with NHibernate 2.0.1. When I add some NHibernate.Search properties config into configuaration file:

<property name="hibernate.search.default.directory_provider">NHibernate.Search.Storage.RAMDirectoryProvider, NHibernate.Search</property>
<property name="hibernate.search.default.indexBase">~\index\</property>

I get an invalid System.Xml.Schema.XmlSchemaException: The Enumeration constraint failed. When I use :

var configuration = new Configuration().Configure();

So how can I solve this problem?

like image 720
Samnang Avatar asked Dec 02 '25 22:12

Samnang


1 Answers

Make sure that the NHibernate.Search properties you define are included in the nhs-configuration block and not in the standard NHibernate configuration block. Your web.config should look like this:

<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
<section name="nhs-configuration" type="NHibernate.Search.Cfg.ConfigurationSectionHandler, NHibernate.Search" />

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <!-- nhibernate configuration block -->
</hibernate-configuration>

<nhs-configuration xmlns='urn:nhs-configuration-1.0'>
    <search-factory>
        <property name='hibernate.search.default.directory_provider'>NHibernate.Search.Store.FSDirectoryProvider, NHibernate.Search</property>

        <property name='hibernate.search.default.indexBase'>...</property>
    </search-factory>
</nhs-configuration>
like image 183
LorenzCK Avatar answered Dec 05 '25 14:12

LorenzCK



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!