HSEARCH000582: Ambiguous backend type: configuration property 'hibernate.search.backend.type' is not set

Hello all.
I’m trying to migrate from wildfly 26 to jakarta EE 10 and wildfy 27.
Previously, having hibernate search 5, I set the equivalent properties to the persistence unit I wanted and all was OK.
Now, if I have the following senario, this error occurs

<?xml version="1.0"?>
<persistence xmlns="https://jakarta.ee/xml/ns/persistence"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:schemaLocation="https://jakarta.ee/xml/ns/persistence https://jakarta.ee/xml/ns/persistence/persistence_3_1.xsd"
             version="3.1">
    <persistence-unit name="ds1">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>java:/ds1</jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.max_fetch_depth" value="4" />
            <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />
            <property name="hibernate.jdbc.use_get_generated_keys" value="true" />
            <property name="hibernate.search.enabled" value="true" />
            <property name="hibernate.search.backend.type" value="lucene" />
            <property name="hibernate.search.backend.lucene_version" value="LUCENE_8_1_1" />
            <property name="hibernate.search.backend.directory.type" value="local-filesystem" />
            <property name="hibernate.search.backend.directory.root" value="C:\\DEVELOPMENT\\LUCENE\\indexes" />
        </properties>
    </persistence-unit>
    <persistence-unit name="ds2">
        <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
        <jta-data-source>java:/ds2</jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.max_fetch_depth" value="4" />
            <property name="hibernate.temp.use_jdbc_metadata_defaults" value="false" />
            <property name="hibernate.jdbc.use_get_generated_keys" value="true" />
            <property name="hibernate.search.enabled" value="true" />
            <property name="hibernate.search.backend.type" value="lucene" />
            <property name="hibernate.search.backend.lucene_version" value="LUCENE_8_1_1" />
            <property name="hibernate.search.backend.directory.type" value="local-filesystem" />
            <property name="hibernate.search.backend.directory.root" value="C:\\DEVELOPMENT\\LUCENE\\indexes" />
        </properties>
    </persistence-unit>
    <persistence-unit name="ds3">
        <jta-data-source>java:/ds3</jta-data-source>
        <properties>
            <property name="hibernate.dialect" value="com.gatewaynet.epayments.core.persistence.SQLServer2008DialectWithNvarchar"/>
            <property name="hibernate.show_sql" value="false"/>
        </properties>
    </persistence-unit>
</persistence>

but If i add

<property name="hibernate.search.backend.type" value="lucene" />

to the last persistence unit, application starts without a problem.
Is this a bug or works-as-designed and all persistence units need this property from now on?

Thank you!

Apostolos

Hey Apostolos,

Wildfly 27 has integrated Hibernate Search 6.1.

That error you’ve mentioned means that there are both elasticsearch and lucene backends available to the app:

If you have multiple backend types available in the classpath for some reason, but only want to use one, set hibernate.search.backend.type to either lucene or elasticsearch.

So I suppose you can either explicitly pick the backend you would like to use as you’ve done by setting the property. Or alternatively, you can update your module config to exclude the elasticsearch backend

 <!-- Backend modules are optionally depended upon, so we need to ensure they are provisioned.
      Users can exclude one or the other in their provisioning config if they wish. -->
<package name="org.hibernate.search.backend.lucene" optional="true"/>
<package name="org.hibernate.search.backend.elasticsearch" optional="true"/>

OK what I finally saw is that with hibernate search 6 you need to explicitly set a property when having multiple backends like in wildfly 27.

So by having just one persistence unit, just setting the hibernate search properties worked.
If, though, you have multiple persistence units, then you need to expicitly set the hibernate search properties to each persistence unit, something that wasnt necessary with hibernate search 5.

So since I dont need hibernate search for the other persistence units, I just set

<property name="hibernate.search.enabled" value="false" />

and it worked.
Just wanted to see that this is not a bug and the de-facto procedure when having this senario.

Thnx

Hey,

Assuming you have @Indexed annotations in those other persistence units, yes that’s expected and this is the correct solution.