Skip to content

Commit

Permalink
hsearch-es: Upgrade to Hibernate Search 6.0.0.Beta6
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Apr 2, 2020
1 parent 638302c commit cf40509
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 29 deletions.
4 changes: 2 additions & 2 deletions bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,12 @@
<classmate.version>1.3.4</classmate.version>
<hibernate-orm.version>5.4.13.Final</hibernate-orm.version>
<hibernate-validator.version>6.1.2.Final</hibernate-validator.version>
<hibernate-search.version>6.0.0.Beta5</hibernate-search.version>
<hibernate-search.version>6.0.0.Beta6</hibernate-search.version>
<narayana.version>5.10.4.Final</narayana.version>
<jboss-transaction-api_1.2_spec.version>1.1.1.Final</jboss-transaction-api_1.2_spec.version>
<agroal.version>1.7</agroal.version>
<jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
<elasticsearch-rest-client.version>7.6.0</elasticsearch-rest-client.version>
<elasticsearch-rest-client.version>7.6.1</elasticsearch-rest-client.version>
<rxjava1.version>1.3.8</rxjava1.version>
<rxjava.version>2.2.19</rxjava.version>
<wildfly.openssl.version>1.0.6.Final</wildfly.openssl.version>
Expand Down
2 changes: 1 addition & 1 deletion build-parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<properties>
<!-- Maven plugin versions -->
<elasticsearch-maven-plugin.version>6.15</elasticsearch-maven-plugin.version>
<elasticsearch-server.version>7.6.0</elasticsearch-server.version>
<elasticsearch-server.version>7.6.1</elasticsearch-server.version>
<scala-maven-plugin.version>4.1.1</scala-maven-plugin.version>

<!-- These properties are needed in order for them to be resolvable by the generated projects -->
Expand Down
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/hibernate-search-elasticsearch.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ public void onMetadataInitialized(Metadata metadata, BootstrapContext bootstrapC

@Override
public void contributeRuntimeProperties(BiConsumer<String, Object> propertyCollector) {
addConfig(propertyCollector,
HibernateOrmMapperSettings.SCHEMA_MANAGEMENT_STRATEGY,
runtimeConfig.schemaManagement.strategy);
addConfig(propertyCollector,
HibernateOrmMapperSettings.AUTOMATIC_INDEXING_SYNCHRONIZATION_STRATEGY,
runtimeConfig.automaticIndexing.synchronization.strategy);
Expand Down Expand Up @@ -144,28 +147,24 @@ private void contributeBackendRuntimeProperties(BiConsumer<String, Object> 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<String, ElasticsearchIndexConfig> 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());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<IndexLifecycleStrategyName> 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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cf40509

Please sign in to comment.