Cannot resolve method 'index' in 'RestClient'


I'm using ElasticSearch 7.10 and trying to index a very sample document following the documentation from here -

build.gradle has this:-

    compile 'org.elasticsearch:elasticsearch:7.10.1'
    compile 'org.elasticsearch.client:elasticsearch-rest-high-level-client:7.10.1'

And I have a main method I'm initializing rest client like this:-

    RestClient client = RestClient.builder(
                    new HttpHost("localhost", 9200, "http"),
                    new HttpHost("localhost", 9201, "http")).build();

And this is my request I'm trying to make (I just copy pasted from the docs, didn't change anything)

    IndexRequest request = new IndexRequest("posts");"1");
    String jsonString = "{" +
                    "\"user\":\"kimchy\"," +
                    "\"postDate\":\"2013-01-30\"," +
                    "\"message\":\"Elasticsearch\"" +
    request.source(jsonString, XContentType.JSON);

    IndexResponse indexResponse = client.index(request, RequestOptions.DEFAULT);

But it says Cannot resolve method 'index' in 'RestClient'. Even when using BulkRequest, GetRequest either sync or async also it throws the same error. I have used ElasticSearch java client with 7.0 version few months ago and didn't face any issues. But now, the 7.10 java client documentation is very misleading and not helping much.

Read that part of the guide:

Oops! My bad, I took the JAVA API deprecated one for initialization.. Thank you!

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