Skip to content

Latest commit

 

History

History
33 lines (26 loc) · 662 Bytes

File metadata and controls

33 lines (26 loc) · 662 Bytes
endpoint ping
lang java
es_version 9.3
client co.elastic.clients:elasticsearch-java:9.3.0

Elasticsearch 9.3 ping endpoint (Java example)

Use client.ping() to check whether the Elasticsearch server is reachable.

boolean alive = client.ping().value();

if (alive) {
    System.out.println("Elasticsearch is available");
} else {
    System.out.println("Elasticsearch is not reachable");
}

Startup health check

Use ping at application startup to fail fast if Elasticsearch is unavailable:

if (!client.ping().value()) {
    System.err.println("Cannot connect to Elasticsearch — exiting");
    System.exit(1);
}