From cf405091c4327e654b3ed21b3233b632f8e8bc70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Wed, 1 Apr 2020 11:29:32 +0200 Subject: [PATCH] hsearch-es: Upgrade to Hibernate Search 6.0.0.Beta6 --- bom/runtime/pom.xml | 4 +-- build-parent/pom.xml | 2 +- .../hibernate-search-elasticsearch.adoc | 8 +++--- .../HibernateSearchElasticsearchRecorder.java | 23 ++++++++-------- ...rnateSearchElasticsearchRuntimeConfig.java | 27 +++++++++++++------ .../src/main/resources/application.properties | 4 +-- 6 files changed, 39 insertions(+), 29 deletions(-) diff --git a/bom/runtime/pom.xml b/bom/runtime/pom.xml index 8aa72a7d053d6..b081af239653b 100644 --- a/bom/runtime/pom.xml +++ b/bom/runtime/pom.xml @@ -84,12 +84,12 @@ 1.3.4 5.4.13.Final 6.1.2.Final - 6.0.0.Beta5 + 6.0.0.Beta6 5.10.4.Final 1.1.1.Final 1.7 7.6.0.Final - 7.6.0 + 7.6.1 1.3.8 2.2.19 1.0.6.Final diff --git a/build-parent/pom.xml b/build-parent/pom.xml index 9bfb64ff483e8..70e039921ffba 100644 --- a/build-parent/pom.xml +++ b/build-parent/pom.xml @@ -17,7 +17,7 @@ 6.15 - 7.6.0 + 7.6.1 4.1.1 diff --git a/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc b/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc index 96cbb648055b4..9eef50bf94b99 100644 --- a/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc +++ b/docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc @@ -537,8 +537,8 @@ quarkus.hibernate-orm.sql-load-script=import.sql <4> quarkus.hibernate-search.elasticsearch.version=7 <5> quarkus.hibernate-search.elasticsearch.analysis.configurer=org.acme.hibernate.search.elasticsearch.config.AnalysisConfigurer <6> -quarkus.hibernate-search.elasticsearch.index-defaults.lifecycle.strategy=drop-and-create <7> -quarkus.hibernate-search.elasticsearch.index-defaults.lifecycle.required-status=yellow <8> +quarkus.hibernate-search.schema-management.strategy=drop-and-create <7> +quarkus.hibernate-search.elasticsearch.index-defaults.schema-management.required-status=yellow <8> quarkus.hibernate-search.automatic-indexing.synchronization.strategy=sync <9> ---- <1> We won't use SSL so we disable it to have a more compact native executable. @@ -550,7 +550,7 @@ It is important because there are significant differences between Elasticsearch Since the mapping is created at build time to reduce startup time, Hibernate Search cannot connect to the cluster to automatically detect the version. <6> We point to the custom `AnalysisConfigurer` which defines the configuration of our analyzers and normalizers. <7> Obviously, this is not for production: we drop and recreate the index every time we start the application. -<8> We consider the `yellow` status is sufficient to connect to the Elasticsearch cluster. +<8> We consider the `yellow` status is sufficient to proceed after an index is created. This is for testing purposes with the Elasticsearch Docker container. It should not be used in production. <9> This means that we wait for the entities to be searchable before considering a write complete. @@ -601,7 +601,7 @@ Let's use Docker to start one of each: [source, shell] ---- -docker run -it --rm=true --name elasticsearch_quarkus_test -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.5.0 +docker run -it --rm=true --name elasticsearch_quarkus_test -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.6.1 ---- [source, shell] diff --git a/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java b/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java index a50b41de6d1b2..d21d2ef13bd71 100644 --- a/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java +++ b/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRecorder.java @@ -87,6 +87,9 @@ public void onMetadataInitialized(Metadata metadata, BootstrapContext bootstrapC @Override public void contributeRuntimeProperties(BiConsumer propertyCollector) { + addConfig(propertyCollector, + HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY, + runtimeConfig.schemaManagement.strategy); addConfig(propertyCollector, HibernateOrmMapperSettings.AUTOMATIC_INDEXING_SYNCHRONIZATION_STRATEGY, runtimeConfig.automaticIndexing.synchronization.strategy); @@ -144,28 +147,24 @@ private void contributeBackendRuntimeProperties(BiConsumer prope elasticsearchBackendConfig.discovery.refreshInterval.getSeconds()); } - addBackendDefaultIndexConfig(propertyCollector, backendName, ElasticsearchIndexSettings.LIFECYCLE_STRATEGY, - elasticsearchBackendConfig.indexDefaults.lifecycle.strategy); addBackendDefaultIndexConfig(propertyCollector, backendName, - ElasticsearchIndexSettings.LIFECYCLE_MINIMAL_REQUIRED_STATUS, - elasticsearchBackendConfig.indexDefaults.lifecycle.requiredStatus); + ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MINIMAL_REQUIRED_STATUS, + elasticsearchBackendConfig.indexDefaults.schemaManagement.requiredStatus); addBackendDefaultIndexConfig(propertyCollector, backendName, - ElasticsearchIndexSettings.LIFECYCLE_MINIMAL_REQUIRED_STATUS_WAIT_TIMEOUT, - elasticsearchBackendConfig.indexDefaults.lifecycle.requiredStatusWaitTimeout, Optional::isPresent, + ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MINIMAL_REQUIRED_STATUS_WAIT_TIMEOUT, + elasticsearchBackendConfig.indexDefaults.schemaManagement.requiredStatusWaitTimeout, Optional::isPresent, d -> d.get().toMillis()); for (Entry indexConfigEntry : runtimeConfig.defaultBackend.indexes.entrySet()) { String indexName = indexConfigEntry.getKey(); ElasticsearchIndexConfig indexConfig = indexConfigEntry.getValue(); - addBackendIndexConfig(propertyCollector, backendName, indexName, ElasticsearchIndexSettings.LIFECYCLE_STRATEGY, - indexConfig.lifecycle.strategy); addBackendIndexConfig(propertyCollector, backendName, indexName, - ElasticsearchIndexSettings.LIFECYCLE_MINIMAL_REQUIRED_STATUS, - indexConfig.lifecycle.requiredStatus); + ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MINIMAL_REQUIRED_STATUS, + indexConfig.schemaManagement.requiredStatus); addBackendIndexConfig(propertyCollector, backendName, indexName, - ElasticsearchIndexSettings.LIFECYCLE_MINIMAL_REQUIRED_STATUS_WAIT_TIMEOUT, - indexConfig.lifecycle.requiredStatusWaitTimeout, Optional::isPresent, + ElasticsearchIndexSettings.SCHEMA_MANAGEMENT_MINIMAL_REQUIRED_STATUS_WAIT_TIMEOUT, + indexConfig.schemaManagement.requiredStatusWaitTimeout, Optional::isPresent, d -> d.get().toMillis()); } } diff --git a/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfig.java b/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfig.java index 36f625b6d9233..4f36c7e57eb0a 100644 --- a/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfig.java +++ b/extensions/hibernate-search-elasticsearch/runtime/src/main/java/io/quarkus/hibernate/search/elasticsearch/runtime/HibernateSearchElasticsearchRuntimeConfig.java @@ -6,9 +6,9 @@ import java.util.Map; import java.util.Optional; -import org.hibernate.search.backend.elasticsearch.index.IndexLifecycleStrategyName; import org.hibernate.search.backend.elasticsearch.index.IndexStatus; import org.hibernate.search.mapper.orm.automaticindexing.session.AutomaticIndexingSynchronizationStrategyNames; +import org.hibernate.search.mapper.orm.schema.management.SchemaManagementStrategyName; import org.hibernate.search.mapper.orm.search.loading.EntityLoadingCacheLookupStrategy; import org.hibernate.search.util.common.SearchException; import org.hibernate.search.util.common.impl.StringHelper; @@ -37,6 +37,13 @@ public class HibernateSearchElasticsearchRuntimeConfig { @ConfigDocSection public ElasticsearchAdditionalBackendsRuntimeConfig additionalBackends; + /** + * Configuration for automatic creation and validation of the Elasticsearch schema: + * indexes, their mapping, their settings. + */ + @ConfigItem + SchemaManagementConfig schemaManagement; + /** * Configuration for how entities are loaded by a search query. */ @@ -162,10 +169,10 @@ public String getHibernateSearchString() { @ConfigGroup public static class ElasticsearchIndexConfig { /** - * Configuration for the lifecyle of the indexes. + * Configuration for the schema management of the indexes. */ @ConfigItem - LifecycleConfig lifecycle; + ElasticsearchIndexSchemaManagementConfig schemaManagement; } @ConfigGroup @@ -399,18 +406,22 @@ public static class SearchQueryLoadingCacheLookupConfig { EntityLoadingCacheLookupStrategy strategy; } - // We can't set actual default values in this section, - // otherwise "quarkus.hibernate-search.elasticsearch.index-defaults" will be ignored. @ConfigGroup - public static class LifecycleConfig { + public static class SchemaManagementConfig { /** * The strategy used for index lifecycle. */ // We can't set an actual default value here: see comment on this class. - @ConfigItem(defaultValueDocumentation = "create") - Optional strategy; + @ConfigItem(defaultValue = "create-or-validate") + SchemaManagementStrategyName strategy; + } + + // We can't set actual default values in this section, + // otherwise "quarkus.hibernate-search.elasticsearch.index-defaults" will be ignored. + @ConfigGroup + public static class ElasticsearchIndexSchemaManagementConfig { /** * The minimal cluster status required. */ diff --git a/integration-tests/hibernate-search-elasticsearch/src/main/resources/application.properties b/integration-tests/hibernate-search-elasticsearch/src/main/resources/application.properties index 44c278852cd77..f465574d5bf03 100644 --- a/integration-tests/hibernate-search-elasticsearch/src/main/resources/application.properties +++ b/integration-tests/hibernate-search-elasticsearch/src/main/resources/application.properties @@ -10,6 +10,6 @@ quarkus.hibernate-orm.database.generation=drop-and-create quarkus.hibernate-search.elasticsearch.version=7 quarkus.hibernate-search.elasticsearch.analysis.configurer=io.quarkus.it.hibernate.search.elasticsearch.search.DefaultITAnalysisConfigurer -quarkus.hibernate-search.elasticsearch.index-defaults.lifecycle.strategy=drop-and-create-and-drop -quarkus.hibernate-search.elasticsearch.index-defaults.lifecycle.required-status=yellow +quarkus.hibernate-search.elasticsearch.index-defaults.schema-management.required-status=yellow +quarkus.hibernate-search.schema-management.strategy=drop-and-create-and-drop quarkus.hibernate-search.automatic-indexing.synchronization.strategy=sync