Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate types in create index requests. #37134

Merged
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
19accde
Add a deprecation warning to RestCreateIndexAction.
jtibshirani Jan 16, 2019
6892e0f
Introduce a new typeless HLRC method.
jtibshirani Jan 16, 2019
8519ca2
Remove CreateIndexRequest#mapping(Object... source), as it's not as u…
jtibshirani Jan 17, 2019
457a69e
More clean-up in CreateIndexRequest.
jtibshirani Jan 18, 2019
0a6d805
Remove the redundant method CreateIndexRequest#waitForActiveShards.
jtibshirani Jan 18, 2019
6329214
Undo an unintentional change to the server-side CreateIndexResponse.
jtibshirani Jan 18, 2019
c9e20dd
Avoid duplicating all logic in RandomCreateIndexGenerator.
jtibshirani Jan 18, 2019
2762c77
Merge remote-tracking branch 'upstream/master' into pr
jtibshirani Jan 19, 2019
49d8e70
Update PutMappingRequestTests to use the client-side RandomCreateInde…
jtibshirani Jan 19, 2019
3f266f2
Undo an accidental change in IndicesClientDocumentationIT.
jtibshirani Jan 22, 2019
455def3
In the new CreateIndexRequest, avoid extending IndicesRequest.
jtibshirani Jan 22, 2019
9c11c67
Remove some non-critical setters from CreateIndexRequest.
jtibshirani Jan 22, 2019
19efb19
Merge remote-tracking branch 'upstream/master' into deprecate-types-i…
jtibshirani Jan 23, 2019
5d0882e
Merge remote-tracking branch 'upstream/master' into deprecate-types-i…
jtibshirani Jan 23, 2019
196e2ad
Merge remote-tracking branch 'upstream/master' into deprecate-types-i…
jtibshirani Jan 24, 2019
5ad7b3a
Fix a merge conflict.
jtibshirani Jan 24, 2019
f0c7e55
Merge remote-tracking branch 'upstream/master' into deprecate-types-i…
jtibshirani Jan 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheResponse;
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
import org.elasticsearch.action.admin.indices.flush.FlushResponse;
Expand Down Expand Up @@ -59,6 +57,8 @@
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryResponse;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.client.core.ShardsAcknowledgedResponse;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.CreateIndexResponse;
import org.elasticsearch.client.indices.FreezeIndexRequest;
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
Expand Down Expand Up @@ -120,9 +120,10 @@ public void deleteAsync(DeleteIndexRequest deleteIndexRequest, RequestOptions op
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*/
public CreateIndexResponse create(CreateIndexRequest createIndexRequest, RequestOptions options) throws IOException {
public CreateIndexResponse create(CreateIndexRequest createIndexRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(createIndexRequest, IndicesRequestConverters::createIndex, options,
CreateIndexResponse::fromXContent, emptySet());
CreateIndexResponse::fromXContent, emptySet());
}

/**
Expand All @@ -133,9 +134,54 @@ public CreateIndexResponse create(CreateIndexRequest createIndexRequest, Request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*/
public void createAsync(CreateIndexRequest createIndexRequest, RequestOptions options, ActionListener<CreateIndexResponse> listener) {
public void createAsync(CreateIndexRequest createIndexRequest,
RequestOptions options,
ActionListener<CreateIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest, IndicesRequestConverters::createIndex, options,
CreateIndexResponse::fromXContent, listener, emptySet());
CreateIndexResponse::fromXContent, listener, emptySet());
}

/**
* Creates an index using the Create Index API.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
* Create Index API on elastic.co</a>
* @param createIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @return the response
* @throws IOException in case there is a problem sending the request or parsing back the response
*
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The
* method {@link #create(CreateIndexRequest, RequestOptions)} should be used instead, which accepts a new
* request object.
*/
@Deprecated
public org.elasticsearch.action.admin.indices.create.CreateIndexResponse create(
org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest,
RequestOptions options) throws IOException {
return restHighLevelClient.performRequestAndParseEntity(createIndexRequest,
IndicesRequestConverters::createIndex, options,
org.elasticsearch.action.admin.indices.create.CreateIndexResponse::fromXContent, emptySet());
}

/**
* Asynchronously creates an index using the Create Index API.
* See <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-create-index.html">
* Create Index API on elastic.co</a>
* @param createIndexRequest the request
* @param options the request options (e.g. headers), use {@link RequestOptions#DEFAULT} if nothing needs to be customized
* @param listener the listener to be notified upon request completion
*
* @deprecated This method uses an old request object which still refers to types, a deprecated feature. The
* method {@link #createAsync(CreateIndexRequest, RequestOptions, ActionListener)} should be used instead,
* which accepts a new request object.
*/
@Deprecated
public void createAsync(org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest,
RequestOptions options,
ActionListener<org.elasticsearch.action.admin.indices.create.CreateIndexResponse> listener) {
restHighLevelClient.performRequestAsyncAndParseEntity(createIndexRequest,
IndicesRequestConverters::createIndex, options,
org.elasticsearch.action.admin.indices.create.CreateIndexResponse::fromXContent, listener, emptySet());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.elasticsearch.action.admin.indices.analyze.AnalyzeRequest;
import org.elasticsearch.action.admin.indices.cache.clear.ClearIndicesCacheRequest;
import org.elasticsearch.action.admin.indices.close.CloseIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
import org.elasticsearch.action.admin.indices.flush.FlushRequest;
import org.elasticsearch.action.admin.indices.flush.SyncedFlushRequest;
Expand All @@ -47,6 +46,7 @@
import org.elasticsearch.action.admin.indices.template.delete.DeleteIndexTemplateRequest;
import org.elasticsearch.action.admin.indices.template.put.PutIndexTemplateRequest;
import org.elasticsearch.action.admin.indices.validate.query.ValidateQueryRequest;
import org.elasticsearch.client.indices.CreateIndexRequest;
import org.elasticsearch.client.indices.FreezeIndexRequest;
import org.elasticsearch.client.indices.GetIndexTemplatesRequest;
import org.elasticsearch.client.indices.IndexTemplatesExistRequest;
Expand Down Expand Up @@ -97,7 +97,22 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) {
return request;
}

static Request createIndex(CreateIndexRequest createIndexRequest) throws IOException {
static Request createIndex(CreateIndexRequest createIndexRequest)
throws IOException {
String endpoint = RequestConverters.endpoint(createIndexRequest.indices());
Request request = new Request(HttpPut.METHOD_NAME, endpoint);

RequestConverters.Params parameters = new RequestConverters.Params(request);
parameters.withTimeout(createIndexRequest.timeout());
parameters.withMasterTimeout(createIndexRequest.masterNodeTimeout());
parameters.withWaitForActiveShards(createIndexRequest.waitForActiveShards());

request.setEntity(RequestConverters.createEntity(createIndexRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
}

static Request createIndex(org.elasticsearch.action.admin.indices.create.CreateIndexRequest createIndexRequest)
jtibshirani marked this conversation as resolved.
Show resolved Hide resolved
throws IOException {
String endpoint = RequestConverters.endpoint(createIndexRequest.indices());
Request request = new Request(HttpPut.METHOD_NAME, endpoint);

Expand Down
Loading