Cannot use RestHighLevelClient.performRequest() because of protected access

I'm currently in the process of switching our system from using the TransportClient, to the RestHighLevel client. We are using the Rest Client v5.6 and following these instructions for migrating:

I copied the code from the migration guide into my configuration object, but there's one method that I can't get to from my class.
My problem is, the following line (that is copied from the migration guide) is showing an error in IntelliJ:
Response response = restClient.performRequest("PUT", "my-index", emptyMap(), entity);

The error I see is:
'performRequest()' has protected access in 'org.elasticsearch.client.RestHighLevelClient'
I have confirmed that RestHighLevelClient.performRequest() does have protected access.

Am I misunderstanding how to use the example code?

Here is my config file with the problem code:

package com.sample.web.config;

import org.apache.http.*;
import org.apache.http.entity.ContentType;
import org.apache.http.nio.entity.NStringEntity;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.client.Response;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


import static java.util.Collections.emptyMap;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_REPLICAS;
import static org.elasticsearch.cluster.metadata.IndexMetaData.SETTING_NUMBER_OF_SHARDS;

public class ElasticSearchConfiguration {
private String esClusterName;
private String esHost;
private Integer esPort;

public RestHighLevelClient createESRestHighLevelClient()  throws IOException{
    RestClient lowLevelRestClient = getLowLevelRestClient();
    RestHighLevelClient restClient = new RestHighLevelClient(lowLevelRestClient);

    Settings indexSettings = Settings.builder()
            .put("", esClusterName)

    String payload = XContentFactory.jsonBuilder()
            .field("type", "date")

    HttpEntity entity = new NStringEntity(payload, ContentType.APPLICATION_JSON);

    Response response = restClient.performRequest("PUT", "my-index", emptyMap(), entity);
    if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) {

    return restClient;

private RestClient getLowLevelRestClient() {
    return RestClient.builder(
            new HttpHost(esHost, esPort, "http")).build();


Solved. The restClient object in the migration guide is apparently a Low Level Rest Client, not a High Level Rest Client. Switching it fixed the issue.

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