I have copied exactly the same steps as the documentation elastic8 docs
@Bean
public ElasticsearchClient getElasticSearchClient(){
RestClient restClient = RestClient.builder(
new HttpHost("", 9200)).build();
// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(
restClient, new JacksonJsonpMapper());
// And create the API client
ElasticsearchClient client = new ElasticsearchClient(transport);
return client;
}
and I'm receiving this error
Error it gives
An attempt was made to call a method that does not exist. The attempt was made from the following location:
co.elastic.clients.transport.rest_client.RestClientOptions.addBuiltinHeaders(RestClientOptions.java:170)
The following method did not exist:
'org.elasticsearch.client.RequestOptions$Builder org.elasticsearch.client.RequestOptions$Builder.removeHeader(java.lang.String)'
The method's class, org.elasticsearch.client.RequestOptions$Builder, is available from the following locations:
Saw the library of rest_client that was causing the issue and it's 7.2.
my pom is the following
<parent>
<artifactId>spring-boot-starter-parent</artifactId>
<groupId>org.springframework.boot</groupId>
<version>2.6.2</version>
</parent>
<properties>
<apache.beam.version>2.39.0</apache.beam.version>
<java.version>11</java.version>
<elasticsearch-java.version>7.17.0</elasticsearch-java.version>
<jakarta-json-api.version>2.0.1</jakarta-json-api.version>
<!-- testing... -->
</properties>
<version>latest-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>${elasticsearch-java.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.3</version>
</dependency>