If any Elasticsearch-related extension is present (e.g. quarkus-elasticsearch-rest-client
or quarkus-hibernate-search-orm-elasticsearch
),
Dev Services for Elasticsearch automatically starts an Elasticsearch server in dev mode and when running tests.
So, you don’t have to start a server manually.
The application is configured automatically.
Enabling / Disabling Dev Services for Elasticsearch
Dev Services for Elasticsearch is automatically enabled unless:
-
quarkus.devservices.enabled
is set tofalse
. -
quarkus.elasticsearch.devservices.enabled
is set tofalse
-
the hosts property is configured, depending of the extension used it can be:
-
quarkus.elasticsearch.hosts
-
quarkus.hibernate-search-orm.elasticsearch.hosts
Dev Services for Elasticsearch relies on Docker to start the server. If your environment does not support Docker, you will need to start the server manually, or connect to an already running server.
Shared Elasticsearch
Sometimes you need to share the server between applications. Dev Services for Elasticsearch implements a service discovery mechanism for your multiple Quarkus applications running in dev mode to share a single server.
Dev Services for Elasticsearch starts the container with the quarkus-dev-service-elasticsearch label which is used to identify the container.
|
If you need multiple (shared) servers, you can configure the quarkus.elasticsearch.devservices.service-name
attribute and indicate the server name.
It looks for a container with the same value, or starts a new one if none can be found.
The default service name is elasticsearch
.
Sharing is enabled by default in dev mode, but disabled in test mode.
You can disable the sharing with quarkus.elasticsearch.devservices.shared=false
.
Setting the port
By default, Dev Services for Elasticsearch picks a random port and configures the application.
You can set the port by configuring the quarkus.elasticsearch.devservices.port
property.
Note that the Elasticsearch hosts property is automatically configured with the chosen port.
Configuring the image
Dev Services for Elasticsearch only support Elasticsearch based images, Opensearch is not supported at the moment.
If you need to use a different image than the default one you can configure it via
quarkus.elasticsearch.devservices.image-name=docker.elastic.co/elasticsearch/elasticsearch:7.17.0