The English version of quarkus.io is the official project site. Translated sites are community supported on a best-effort basis.

Servicios de desarrollo para Elasticsearch

Si cualquier extensión relacionada con Elasticsearch está presente (por ejemplo, quarkus-elasticsearch-rest-client o quarkus-hibernate-search-orm-elasticsearch), Dev Services for Elasticsearch inicia automáticamente un servidor de Elasticsearch en modo dev y cuando se ejecutan pruebas. Por lo tanto, no tienes que iniciar un servidor manualmente. La aplicación se configura automáticamente.

Activación/desactivación de los servicios de desarrollo para Elasticsearch

Los servicios de desarrollo para Elasticsearch se activan automáticamente a menos que:

  • quarkus.devservices.enabled se fija en false.

  • quarkus.elasticsearch.devservices.enabled se ajusta a false

  • la propiedad hosts está configurada, dependiendo de la extensión utilizada puede ser:

  • quarkus.elasticsearch.hosts

  • quarkus.hibernate-search-orm.elasticsearch.hosts

Dev Services for Elasticsearch se basa en Docker para iniciar el servidor. Si su entorno no admite Docker, tendrá que iniciar el servidor manualmente o conectarse a un servidor ya en funcionamiento.

Elasticsearch compartido

A veces es necesario compartir el servidor entre aplicaciones. Dev Services for Elasticsearch implementa un mecanismo de descubrimiento de servicios para que sus múltiples aplicaciones Quarkus que se ejecutan en modo dev compartan un único servidor.

Dev Services for Elasticsearch inicia el contenedor con la etiqueta quarkus-dev-service-elasticsearch que se utiliza para identificar el contenedor.

Si necesitas varios servidores (compartidos), puedes configurar el atributo quarkus.elasticsearch.devservices.service-name e indicar el nombre del servidor. Se busca un contenedor con el mismo valor, o se inicia uno nuevo si no se encuentra ninguno. El nombre de servicio por defecto es elasticsearch.

El uso compartido está activado por defecto en el modo de desarrollo, pero está desactivada en el modo de prueba. Puede desactivar el uso compartido con quarkus.elasticsearch.devservices.shared=false.

Ajuste del puerto

Por defecto, Dev Services for Elasticsearch elige un puerto aleatorio y configura la aplicación. Puedes establecer el puerto configurando la propiedad quarkus.elasticsearch.devservices.port.

Tenga en cuenta que la propiedad de hosts de Elasticsearch se configura automáticamente con el puerto elegido.

Configuración de la imagen

Dev Services for Elasticsearch support distributions based on both Elasticsearch and OpenSearch images.

When using Hibernate Search, Dev Services will default to Elasticsearch or OpenSearch based on Hibernate Search configuration.

Otherwise, Dev Services will default to Elasticsearch. To use OpenSearch, configure the distribution explicitly:

quarkus.elasticsearch.devservices.distribution=opensearch

If you need to use a different Elasticsearch or OpenSearch image than the default one you can configure it via:

quarkus.elasticsearch.devservices.image-name=docker.io/elastic/elasticsearch:8.9.1

For exotic image names, Quarkus might be unable to infer the distribution (elastic or opensearch). In these cases starting the Dev Services will fail, and you will need to configure the distribution explicitly:

quarkus.elasticsearch.devservices.image-name=my-custom-image-with-no-clue-about-the-distribution:1.0
quarkus.elasticsearch.devservices.distribution=elasticsearch

Limitaciones actuales

Actualmente, sólo se admite el backend predeterminado para Hibernate Search Elasticsearch, porque Dev Services for Elasticsearch sólo puede iniciar un contenedor de Elasticsearch.

Referencia de configuración

Configuration property fixed at build time - All other configuration properties are overridable at runtime

Configuration property

Type

Default

If Dev Services for Elasticsearch has been explicitly enabled or disabled. Dev Services are generally enabled by default, unless there is an existing configuration present. For Elasticsearch, Dev Services starts a server unless quarkus.elasticsearch.hosts is set.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_ENABLED

Show more

boolean

Optional fixed port the dev service will listen to.

If not defined, the port will be chosen randomly.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_PORT

Show more

int

Defaults to a distribution inferred from the explicitly configured image-name (if any), or by default to the distribution configured in depending extensions (e.g. Hibernate Search), or by default to elastic.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_DISTRIBUTION

Show more

elastic, opensearch

The Elasticsearch container image to use. Defaults depend on the configured distribution:

  • For the elastic distribution: docker.io/elastic/elasticsearch:8.9.1

  • For the opensearch distribution: docker.io/opensearchproject/opensearch:2.9.0

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_IMAGE_NAME

Show more

string

The value for the ES_JAVA_OPTS env variable. Defaults to setting the heap to 512MB min - 1GB max.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_JAVA_OPTS

Show more

string

-Xms512m -Xmx1g

Indicates if the Elasticsearch server managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. If a matching container is found, it is used, and so a second one is not started. Otherwise, Dev Services for Elasticsearch starts a new container.

The discovery uses the quarkus-dev-service-elasticsearch label. The value is configured using the service-name property.

Container sharing is only used in dev mode.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_SHARED

Show more

boolean

true

The value of the quarkus-dev-service-elasticsearch label attached to the started container. This property is used when shared is set to true. In this case, before starting a container, Dev Services for Elasticsearch looks for a container with the quarkus-dev-service-elasticsearch label set to the configured value. If found, it will use this container instead of starting a new one. Otherwise it starts a new container with the quarkus-dev-service-elasticsearch label set to the specified value.

This property is used when you need multiple shared Elasticsearch servers.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_SERVICE_NAME

Show more

string

elasticsearch

Environment variables that are passed to the container.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_CONTAINER_ENV

Show more

Map<String,String>