extensions/elasticsearch-java-client/deployment/src/main/resources/META-INF/quarkus-skill.md
@Inject ElasticsearchClient client; // synchronous
@Inject ElasticsearchAsyncClient asyncClient; // async
Both are from the co.elastic.clients.elasticsearch package (Elasticsearch Java Client co.elastic.clients:elasticsearch-java).
client.indices().create(c -> c
.index("products"));
Product product = new Product(1, "laptop", 999.99);
client.index(i -> i
.index("products")
.id(Objects.toString(product.id())) // if a document with this ID already exists, it will be updated
.document(product));
SearchResponse<Product> response = client.search(s -> s
.index("products")
.query(q -> q
.match(m -> m
.field("name")
.query("laptop"))),
Product.class);
List<Hit<Product>> hits = response.hits().hits();
hits.forEach(hit -> {
Product p = hit.source();
});
# Dev Services auto-starts Elasticsearch — no config needed in dev/test
# Production (use %prod. prefix to avoid overriding Dev Services in dev/test):
%prod.quarkus.elasticsearch.hosts=localhost:9200
%prod.quarkus.elasticsearch.username=elastic
%prod.quarkus.elasticsearch.password=changeme
An Elasticsearch container starts automatically in dev/test mode. No configuration needed.
co.elastic.clients package — not the old org.elasticsearch.client (High Level REST Client is deprecated).CompletableFuture — not Mutiny Uni. Wrap with Uni.createFrom().completionStage() if needed.