Elasticsearch 8 Client is giving error The following method did not exist: ‘org.elasticsearch.client.RequestOptions$Builder org.elasticsearch.client.RequestOptions$Builder.removeHeader(java.lang.String)’

I have copied exactly the same steps as the documentation elastic8 docs

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:


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



    <!-- testing... -->




Welcome! Have a look at the dependency tree.

It will probably show you that you are not using the right version of the low level client.

Looks like it's the apache beam who's downloading the dependency of

- org.apache.beam:beam-sdks-java-io-elasticsearch:jar:2.39.0:compile
[INFO] |  +- org.apache.httpcomponents:httpasyncclient:jar:4.1.5:compile
[INFO] |  +- org.apache.httpcomponents:httpcore-nio:jar:4.4.15:compile
[INFO] |  \- org.elasticsearch.client:elasticsearch-rest-client:jar:7.15.2:compile

I made the exclusion from apache beam


my dependency tree looks like

 +- co.elastic.clients:elasticsearch-java:jar:8.8.0:compile
[INFO] |  +- org.elasticsearch.client:elasticsearch-rest-client:jar:7.15.2:compile
[INFO] |  \- org.eclipse.parsson:parsson:jar:1.0.0:compile

and still receives the same error

You need to use 7.17.10 or 7.17.11 for both clients.

does that mean the 8.8 doesn't work or what? I'm not sure I get your answer

In your Pom, you set 7.17.0 as the version. So I guessed you are using a 7.17.0 version. Am I wrong?

What is your Elasticsearch server version?

my bad. I switched my pom to using the 8.8 version. copied the previous pom

the ES version I'm using is 8.
the lib version is 8.8
the rest-client downloaded via the lib is 7.5
the issue is still there

the rest-client downloaded via the lib is 7.5

No. It's not the lib. It's probably a problem with the spring parent.

So you should "force" the low level client:


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.