@Bean
public RestHighLevelClient restClient() {
ClientConfiguration clientConfiguration = ClientConfiguration.builder()
.connectedTo("hostandport")
.usingSsl()
.withBasicAuth("username", "password")
.build();
return RestClients.create(clientConfiguration).rest();
}
can I use spring data elasticsearch to connect to elastic cloud and fetch the data? Do I need any config else than restclient configuration, to fetch the data from Elastic cloud?
Why not? Add the cluster URL(s), the authentication either as basic auth or header (https://www.elastic.co/guide/en/cloud/current/ec_connect_a_client.html) and you should be fine.