Using elastic client with latest version for various operations

Hi,

I am trying to migrate my java client to 8.11 stack from 7.17. Earlier, I had to pass auth token as request options in all requests.
Now, there are so many incompatible methods where I dont see option to pass request option. for example, below code to create index.

CreateIndexRequest createIndexRequest = CreateIndexRequest.of( b -> b.index(indexName.getIndexName())
    .withJson(file).settings(IndexSettings.of( s -> s.numberOfReplicas(String.valueOf(replicaCount))
        .shards(shardCount))));

I see way to set option at RestClient level, but that means for each request, I need to build a new restclient to take care of token expiry?
Can you please point to proper migration guide(I doubt existing is covering all topics.)

I am getting below exception currently due to client versioning issue.

Caused by: java.util.concurrent.CancellationException: Request execution cancelled
at org.apache.http.impl.nio.client.CloseableHttpAsyncClientBase.execute(CloseableHttpAsyncClientBase.java:114)
at org.apache.http.impl.nio.client.InternalHttpAsyncClient.execute(InternalHttpAsyncClient.java:138)
at org.elasticsearch.client.RestClient.performRequest(RestClient.java:296)

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