From 9041d1b34dcfe5906621ad7f41aed43d36407041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yoann=20Rodi=C3=A8re?= Date: Thu, 16 Jun 2022 10:35:09 +0200 Subject: [PATCH] Hibernate Search documentation: take advantage of defaults --- .../hibernate-search-orm-elasticsearch.adoc | 51 ++++++++++++------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/docs/src/main/asciidoc/hibernate-search-orm-elasticsearch.adoc b/docs/src/main/asciidoc/hibernate-search-orm-elasticsearch.adoc index 514b39d378795..0acf83b7c89e8 100644 --- a/docs/src/main/asciidoc/hibernate-search-orm-elasticsearch.adoc +++ b/docs/src/main/asciidoc/hibernate-search-orm-elasticsearch.adoc @@ -544,40 +544,57 @@ quarkus.ssl.native=false <1> quarkus.datasource.db-kind=postgresql <2> -%dev.quarkus.hibernate-orm.database.generation=drop-and-create <3> -%test.quarkus.hibernate-orm.database.generation=drop-and-create <3> -quarkus.hibernate-orm.sql-load-script=import.sql <4> +quarkus.hibernate-orm.sql-load-script=import.sql <3> -quarkus.hibernate-search-orm.elasticsearch.version=7 <5> -quarkus.hibernate-search-orm.elasticsearch.analysis.configurer=bean:myAnalysisConfigurer <6> -%dev.quarkus.hibernate-search-orm.schema-management.strategy=drop-and-create <7> -%test.quarkus.hibernate-search-orm.schema-management.strategy=drop-and-create <7> -quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=sync <8> +quarkus.hibernate-search-orm.elasticsearch.version=7 <4> +quarkus.hibernate-search-orm.elasticsearch.analysis.configurer=bean:myAnalysisConfigurer <5> +quarkus.hibernate-search-orm.automatic-indexing.synchronization.strategy=sync <6> -%prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost/quarkus_test <9> +%prod.quarkus.datasource.jdbc.url=jdbc:postgresql://localhost/quarkus_test <7> %prod.quarkus.datasource.username=quarkus_test %prod.quarkus.datasource.password=quarkus_test -%prod.hibernate-search-orm.elasticsearch.hosts=localhost:9200 <9> +%prod.quarkus.hibernate-orm.database.generation=create +%prod.hibernate-search-orm.elasticsearch.hosts=localhost:9200 <7> ---- <1> We won't use SSL, so we disable it to have a more compact native executable. <2> Let's create a PostgreSQL datasource. -<3> In dev mode and in tests, we will drop and recreate the schema on startup. -<4> We load some initial data on startup. -<5> We need to tell Hibernate Search about the version of Elasticsearch we will use. +<3> We load some initial data on startup. +<4> We need to tell Hibernate Search about the version of Elasticsearch we will use. It is important because there are significant differences between Elasticsearch mapping syntax depending on the version. Since the mapping is created at build time to reduce startup time, Hibernate Search cannot connect to the cluster to automatically detect the version. Note that, for OpenSearch, you need to prefix the version with `opensearch:`; see <>. -<6> We point to the custom `AnalysisConfigurer` which defines the configuration of our analyzers and normalizers. -<7> In dev mode and in tests, we will drop and recreate the index on startup. -<8> This means that we wait for the entities to be searchable before considering a write complete. +<5> We point to the custom `AnalysisConfigurer` which defines the configuration of our analyzers and normalizers. +<6> This means that we wait for the entities to be searchable before considering a write complete. On a production setup, the `write-sync` default will provide better performance. Using `sync` is especially important when testing as you need the entities to be searchable immediately. -<9> For development and tests, we rely on <>, +<7> For development and tests, we rely on <>, which means Quarkus will start a PostgreSQL database and Elasticsearch cluster automatically. In production mode, however, you will want to start a PostgreSQL database and Elasticsearch cluster manually, which is why we provide Quarkus with this connection info in the `prod` profile (`%prod.` prefix). +[NOTE] +==== +Because we rely on <>, the database and Elasticsearch schema +will automatically be dropped and re-created on each application startup +in tests and dev mode +(unless link:#quarkus-hibernate-search-orm-elasticsearch_quarkus.hibernate-search-orm.schema-management.strategy[`quarkus.hibernate-search-orm.schema-management.strategy`] is set explicitly). + +If for some reason you cannot use Dev Services, +you will have to set the following properties to get similar behavior: + +[source,properties] +---- +%dev.quarkus.hibernate-orm.database.generation=drop-and-create +%test.quarkus.hibernate-orm.database.generation=drop-and-create +%dev.quarkus.hibernate-search-orm.schema-management.strategy=drop-and-create +%test.quarkus.hibernate-search-orm.schema-management.strategy=drop-and-create +---- + +See also link:#quarkus-hibernate-search-orm-elasticsearch_quarkus.hibernate-search-orm.schema-management.strategy[`quarkus.hibernate-search-orm.schema-management.strategy`]. +==== + + [TIP] For more information about the Hibernate Search extension configuration please refer to the <>.