Java High Level Rest Create Index API

I'm getting the error:
Type mismatch: cannot convert from org.elasticsearch.action.admin.indices.create.CreateIndexResponse to org.elasticsearch.client.indices.CreateIndexResponse

CreateIndexRequest request = new CreateIndexRequest("index"); 

request.settings(Settings. builder () 

.put("index.number_of_shards", 3)

.put("index.number_of_replicas", 2)

);

CreateIndexResponse createIndexResponse = client.indices().create(request, RequestOptions.DEFAULT);

Can anyone help me with this please?

Thank you!

Change the import line in your class I think.

From:

import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;

to

import org.elasticsearch.client.indices.CreateIndexResponse;

It seems Eclipse was adding
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
when it should have been
import org.elasticsearch.client.indices.CreateIndexRequest;

Thank you!

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