Dynamic mapping setting for indices does not seem to be working

Using these properties at the moment with 6.0.0.Final version, all properties are getting picked and used except the dynamic_mapping one in the end. Verified by using drop-and-create strategy, and checking mapping in Elasticsearch.

spring.jpa.properties.hibernate.search.enabled=true
spring.jpa.properties.hibernate.search.backend.uris=http://127.0.0.1:9500
spring.jpa.properties.hibernate.search.schema_management.strategy=create
spring.jpa.properties.hibernate.search.backend.schema_management.minimal_required_status=green
spring.jpa.properties.hibernate.search.backend.analysis.configurer=io.avidsecure.search.CustomAnalyzer
spring.jpa.properties.hibernate.search.backend.layout.strategy=io.avidsecure.search.CustomIndexLayoutStrategy
spring.jpa.properties.hibernate.search.automatic_indexing.synchronization.strategy=io.avidsecure.search.CustomSynchronizationStrategy
spring.jpa.properties.hibernate.search.backend.dynamic_mapping=true

This schema management strategy will not touch any existing indexes, and leave them as they are.

Do your indexes already exist? If so, what happens if you switch the schema management strategy to create-or-validate?

I updated the question with how I verified the setting, I actually used drop-and-create.

Ah… actually you’re right, there’s a bug.

As a workaround for now, try using spring.jpa.properties.hibernate.search.backend.indexing.dynamic_mapping=true.

Let me quickly try and check that.

Yep, this one seems to be working :slight_smile: I think we should update the online documentation as well, till it is sorted?

Actually the documentation is right, the implementation and tests are wrong. We’ll fix them in 6.0.2.Final: [HSEARCH-4152] "hibernate.search.backend.dynamic_mapping" is ignored - Hibernate JIRA

1 Like

Yes, I meant the document for it is not corresponding to the latest released version. But I also see what you mean. If 6.0.2.Final is around the corner, then I guess we keep the document as is.

Changing the documentation requires a release, so if we release we might as well fix the bug rather than changing the documentation :slight_smile:

Haha… Right :+1: Thanks for the help.

For anyone else having this problem: this will be fixed in 6.0.2.Final through HSEARCH-4152.

In the meantime, just use this configuration, to be sure it works both in 6.0.0.Final/6.0.1.Final (buggy) and 6.0.2.Final (fixed):

spring.jpa.properties.hibernate.search.backend.dynamic_mapping=true
spring.jpa.properties.hibernate.search.backend.indexing.dynamic_mapping=true

EDIT: 6.0.2.Final is out.