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
Changes from 1 commit
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
Next Next commit
Add a deprecation warning to RestCreateIndexAction.
  • Loading branch information
jtibshirani committed Jan 18, 2019
commit 19accdeb26f857f29f5f7e4aa36578dd4eab5c8f
Original file line number Diff line number Diff line change
@@ -19,9 +19,11 @@

package org.elasticsearch.rest.action.admin.indices;

import org.apache.logging.log4j.LogManager;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.support.ActiveShardCount;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.LoggingDeprecationHandler;
import org.elasticsearch.common.xcontent.XContentHelper;
@@ -37,6 +39,11 @@
import java.util.Map;

public class RestCreateIndexAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = new DeprecationLogger(
LogManager.getLogger(RestPutMappingAction.class));
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Using include_type_name in create " +
"index requests is deprecated. The parameter will be removed in the next major version.";

public RestCreateIndexAction(Settings settings, RestController controller) {
super(settings);
controller.registerHandler(RestRequest.Method.PUT, "/{index}", this);
@@ -51,6 +58,11 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
final boolean includeTypeName = request.paramAsBoolean(INCLUDE_TYPE_NAME_PARAMETER,
DEFAULT_INCLUDE_TYPE_NAME_POLICY);

if (request.hasParam(INCLUDE_TYPE_NAME_PARAMETER)) {
deprecationLogger.deprecatedAndMaybeLog("create_index_with_types", TYPES_DEPRECATION_MESSAGE);
}

CreateIndexRequest createIndexRequest = new CreateIndexRequest(request.param("index"));
if (request.hasContent()) {
Map<String, Object> sourceAsMap = XContentHelper.convertToMap(request.content(), false, request.getXContentType()).v2();
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Licensed to Elasticsearch under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package org.elasticsearch.rest.action.admin.indices;

import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.test.rest.FakeRestRequest;
import org.elasticsearch.test.rest.RestActionTestCase;
import org.junit.Before;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import static org.elasticsearch.rest.BaseRestHandler.INCLUDE_TYPE_NAME_PARAMETER;
import static org.mockito.Mockito.mock;

public class RestCreateIndexActionTests extends RestActionTestCase {
private RestCreateIndexAction action;

@Before
public void setupAction() {
action = new RestCreateIndexAction(Settings.EMPTY, controller());
}

public void testIncludeTypeName() throws IOException {
Map<String, String> params = new HashMap<>();
params.put(INCLUDE_TYPE_NAME_PARAMETER, randomFrom("true", "false"));
RestRequest deprecatedRequest = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(RestRequest.Method.PUT)
.withPath("/some_index")
.withParams(params)
.build();

action.prepareRequest(deprecatedRequest, mock(NodeClient.class));
assertWarnings(RestCreateIndexAction.TYPES_DEPRECATION_MESSAGE);

RestRequest validRequest = new FakeRestRequest.Builder(xContentRegistry())
.withMethod(RestRequest.Method.PUT)
.withPath("/some_index")
.build();
action.prepareRequest(validRequest, mock(NodeClient.class));
}
}