HSEARCH000603 Exception: Inconsistency of dslConverter Attribute in Hibernate Searc

Hello everyone,

I’m currently working on implementing Hibernate Search version 7.1.0, utilizing programmatic mapping through the configure method in HibernateOrmMappingConfigurationContext. My setup involves 11 entities that inherit from a common base class and specify their own indexes. I’ve encountered an issue with mapping the solvent field, which is present in several of these entities but not all. Moreover, this field, despite sharing the same name across different entities, refers to different enum types, such as FirstSolventType, SecondSolventType, etc.

Attempting to create appropriate valueBinders or valueBridges for them results in receiving an error about inconsistent configuration for the solvent field during a search query, with specific details pointing to differences in the dslConverter attribute.

An example implementation for SecondSolventTypeValueBinder and SecondSolventTypeValueBridge looks like this:

public class SecondSolventTypeValueBinder implements ValueBinder {
    @Override
    public void bind(ValueBindingContext<?> context) {
        context.bridge(SecondSolventType.class, new SecondSolventTypeValueBridge(), context.typeFactory().asString());
    }
}

public class SecondSolventTypeValueBridge implements ValueBridge<SecondSolventType, String> {
    @Override
    public String toIndexedValue(SecondSolventType enumValue, ValueBridgeToIndexedValueContext context) {
        return enumValue == null ? null : enumValue.name();
    }

    @Override
    public SecondSolventType fromIndexedValue(String indexedValue, ValueBridgeFromIndexedValueContext context) {
        return indexedValue == null ? null : SecondSolventType.valueOf(indexedValue);
    }

    @Override
    public boolean isCompatibleWith(ValueBridge<?, ?> other) {
        return getClass().equals(other.getClass());
    }
}

Mapping assignment is done like this:

propertyMapping(mapping, exampleEntity.solvent).keywordField().valueBinder(new FirstSolventTypeValueBinder());

I tried also with fullTextField(), generifFiled().

I aim to enable data searching using Hibernate Search session, employing constructs like f.match().field(field).matching(value). However, I’m facing an issue with inconsistent configuration and am unsure how to resolve it.

Additionally, I receive the following stack trace regarding the issue:

csharpCopy code

Caused by: org.hibernate.search.util.common.SearchException: HSEARCH000603: Attribute 'dslConverter' differs: 'DslConverter[valueType=com.example.project.model.FirstSolventType,delegate=PojoValueBridgeDocumentValueConverter[com.example.project.config.FirstSolventTypeValueBridge@5aa3ccfd]]' vs. 'DslConverter[valueType=com.example.project.model.SecondSolventType,delegate=PojoValueBridgeDocumentValueConverter[com.example.project.config.SecondSolventTypeValueBridge@7247facd]]'.
	at org.hibernate.search.engine.search.common.spi.AbstractMultiIndexSearchIndexNodeContext.checkAttributeCompatibility(AbstractMultiIndexSearchIndexNodeContext.java:195)
	... 117 more

Could anyone suggest how to address this problem?

Thank you in advance for your assistance.

You should read these parts of the documentation:

Short answer: use f.match().field(field).matching(value, ValueConvert.NO) and pass a String value.

Alternatively, in the field type definition, set a dslConverter explicitly and make sure to use the same implementation across all your solvent type binders.

1 Like