Getting cluster health from an es-7 cluster using the elasticsearch-java
(es8) language client does not work out of the box. How do I configure the client in a compatible way?
We are finishing our migration from es7 clients to the newer elasticsearch-java client for es8.
I would like to return a cluster health response using the elasticsearch-java
, es8 client talking to an es7 server cluster using the following code:
@Service
public class OurService {
//...
private final ElasticsearchClient client;
//...
@Autowired
public OurService(final @NotNull ElasticsearchClient client) {
//...
this.client = client;
}
public HealthResponse getHealth() throws IOException {
return this.client.cluster().health();
}
//...
}
I configured the client as follows:
//...
public static @NotNull ElasticsearchClient createElasticsearchClient(
final @NotNull RestClient restClient,
final @NotNull JacksonJsonpMapper jacksonJsonpMapper) {
//final var transport = new RestClientTransport(restClient, jacksonJsonpMapper); //original code
final TransportOptions transportOptions = null;//How to configure the TransportOptions?
final var transport = new RestClientTransport(restClient, jacksonJsonpMapper, transportOptions);
return new ElasticsearchClient(transport);
}
//...
How should I configure the TransportOptions?
Here all kinds of AI hallucinate the most beautiful non-existing solutions.
Some human guidance is appreciated here.