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

  • the hosts property is configured, depending on the extension used it can be:

  • 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 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={elasticsearch-image}

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

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

int

The Elasticsearch container image to use. Defaults to the elasticsearch image provided by Elastic.

Environment variable: QUARKUS_ELASTICSEARCH_DEVSERVICES_IMAGE_NAME

string

docker.elastic.co/elasticsearch/elasticsearch:7.17.0

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

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

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

string

elasticsearch