Elastic 7.x CreateIndexRequest Deprecated

This Elastic test example below generates a deprecation warning in 7.x up thru 7.1.
It is documented at:
https://www.elastic.co/guide/en/elasticsearch/client/java-rest/current/java-rest-high-create-index.html

When browsing thru the methods in Eclipse (past indices().), the CreateIndexRequest appears twice, with the first marked as deprecated.

CreateIndexResponse createIndexResponse = client.indices().create(new CreateIndexRequest("twitter"), RequestOptions.DEFAULT);

Both methods are using different classes indeed.
The old one which is something more internal has been deprecated when used within the REST Client.

So you need to use the right one. :slight_smile:

Thanks for the quick response. Still getting fooled on this one, as all parms and return type for both methods are the same.

When I select the non-deprecated one (based on your indication that I need to select the right one), I still get the same error.

I'm providing the mapping as a JSON string to the request, which varies from the high level REST example which uses XContentType. Could this be an issue?

Here is what I'm doing with 7.1.0:

The class I'm importing is:

import org.elasticsearch.client.indices.CreateIndexRequest;

HTH

Thanks, I love a working example

David, resolved the issue by correction the imports (they were used the 'admin' version, which probably were tied to the transport client.

Thanks

Hi David,

just for clarification, while the CreateIndexRequest moved to package org.elasticsearch.client.indices
the DeleteIndexRequest stayed in org.elasticsearch.action.admin.indices.delete?

In general, just as an idea/wish, would it be possible in the future to link javadoc or a working example / testcase to the documentation of the client? I think this thread shows that the import part or at least more that just a line without the complete class reference including packages can be helpful.

Thanks!

Apparently yes. May be that will move in the future (I hope it will).

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