Elasticsearch 8 is expecting some class RequestOptions which is present in elasticsearch-rest-client-7.6.2.jar.
How I can resolve this error done exactly in a way mentioned in 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;
}
POM.xml
<jackson.version>2.11.3</jackson.version>
</properties>
<dependencies>
<dependency>
<groupId>co.elastic.clients</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.6.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>com.fasterxml.jackson.core</groupId>-->
<!-- <artifactId>jackson-databind</artifactId>-->
<!-- <version>2.12.3</version>-->
<!-- </dependency>-->
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.0.1</version>
</dependency>
--------------------
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:
jar:file:/Users/sureshc1/.m2/repository/org/elasticsearch/client/elasticsearch-rest-client/7.6.2/elasticsearch-rest-client-7.6.2.jar!/org/elasticsearch/client/RequestOptions$Builder.class
-------------
MY analysis
the Class elastic 8 uses RestClient is present in elastic 7 when I search in documentation in elastic8 it is not present.
RequestOPtions is also present in elastic 7 only it is not present in 8
kindly help here