# Cannot resolve method 'index' in 'RestClient'

**URL:** <https://discuss.elastic.co/t/cannot-resolve-method-index-in-restclient/259188>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 20, 2020, 7:16am UTC](https://discuss.elastic.co/t/cannot-resolve-method-index-in-restclient/259188 "2020-12-20T07:16:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Murigipudi\_Revanth](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Murigipudi\_Revanth](https://discuss.elastic.co/u/Murigipudi_Revanth)\
**Post date:** [December 20, 2020, 7:16am UTC](https://discuss.elastic.co/t/cannot-resolve-method-index-in-restclient/259188/1 "2020-12-20T07:16:20Z")

</div>

Hello,

I'm using ElasticSearch 7.10 and trying to index a very sample document following the documentation from here - [https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-index.html](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-document-index.html)

build.gradle has this:-

```auto
    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:-

```auto
    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)

```auto
    IndexRequest request = new IndexRequest("posts");
    request.id("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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [December 20, 2020, 8:19am UTC](https://discuss.elastic.co/t/cannot-resolve-method-index-in-restclient/259188/2 "2020-12-20T08:19:58Z")

</div>

Read that part of the guide:

> **[Initialization | Java REST Client \[7.10\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-getting-started-initialization.html)**

---

<div class="post-metadata">

**Author:** ![Murigipudi\_Revanth](https://avatars.discourse-cdn.com/v4/letter/m/4491bb/32.png) [@Murigipudi\_Revanth](https://discuss.elastic.co/u/Murigipudi_Revanth)\
**Post date:** [December 20, 2020, 8:23am UTC](https://discuss.elastic.co/t/cannot-resolve-method-index-in-restclient/259188/3 "2020-12-20T08:23:50Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [January 17, 2021, 8:24am UTC](https://discuss.elastic.co/t/cannot-resolve-method-index-in-restclient/259188/4 "2021-01-17T08:24:14Z")

</div>

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