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

[Remove] Type mapping parameter from document delete API #2213

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -624,8 +624,7 @@ void assertRealtimeGetWorks(final String typeName) throws IOException {
Map<?, ?> hit = (Map<?, ?>) ((List<?>)(XContentMapValues.extractValue("hits.hits", searchResponse))).get(0);
String docId = (String) hit.get("_id");

Request updateRequest = new Request("POST", "/" + index + "/" + typeName + "/" + docId + "/_update");
updateRequest.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE));
Request updateRequest = new Request("POST", "/" + index + "/_update/" + docId);
updateRequest.setJsonEntity("{ \"doc\" : { \"foo\": \"bar\"}}");
client().performRequest(updateRequest);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,6 @@ public void testUpdateDoc() throws Exception {
for (int i = 0; i < times; i++) {
long value = randomNonNegativeLong();
Request update = new Request("POST", index + "/_update/" + docId);
update.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE));
update.setJsonEntity("{\"doc\": {\"updated_field\": " + value + "}}");
client().performRequest(update);
updates.put(docId, value);
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.opensearch.action.delete.DeleteRequest;
import org.opensearch.action.support.ActiveShardCount;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.index.VersionType;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
Expand All @@ -50,19 +49,10 @@
import static org.opensearch.rest.RestRequest.Method.DELETE;

public class RestDeleteAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestDeleteAction.class);
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in "
+ "document index requests is deprecated, use the /{index}/_doc/{id} endpoint instead.";

@Override
public List<Route> routes() {
return unmodifiableList(
asList(
new Route(DELETE, "/{index}/_doc/{id}"),
// Deprecated typed endpoint.
new Route(DELETE, "/{index}/{type}/{id}")
)
);
return unmodifiableList(asList(new Route(DELETE, "/{index}/_doc/{id}"), new Route(DELETE, "/{index}/{id}")));
}

@Override
Expand All @@ -73,12 +63,7 @@ public String getName() {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
DeleteRequest deleteRequest;
if (request.hasParam("type")) {
deprecationLogger.deprecate("delete_with_types", TYPES_DEPRECATION_MESSAGE);
deleteRequest = new DeleteRequest(request.param("index"), request.param("type"), request.param("id"));
} else {
deleteRequest = new DeleteRequest(request.param("index"), request.param("id"));
}
deleteRequest = new DeleteRequest(request.param("index"), request.param("id"));

deleteRequest.routing(request.param("routing"));
deleteRequest.timeout(request.paramAsTime("timeout", DeleteRequest.DEFAULT_TIMEOUT));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
import org.opensearch.action.support.ActiveShardCount;
import org.opensearch.action.update.UpdateRequest;
import org.opensearch.client.node.NodeClient;
import org.opensearch.common.logging.DeprecationLogger;
import org.opensearch.index.VersionType;
import org.opensearch.rest.BaseRestHandler;
import org.opensearch.rest.RestRequest;
Expand All @@ -54,19 +53,10 @@
import static org.opensearch.rest.RestRequest.Method.POST;

public class RestUpdateAction extends BaseRestHandler {
private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestUpdateAction.class);
public static final String TYPES_DEPRECATION_MESSAGE = "[types removal] Specifying types in "
+ "document update requests is deprecated, use the endpoint /{index}/_update/{id} instead.";

@Override
public List<Route> routes() {
return unmodifiableList(
asList(
new Route(POST, "/{index}/_update/{id}"),
// Deprecated typed endpoint.
new Route(POST, "/{index}/{type}/{id}/_update")
)
);
return unmodifiableList(asList(new Route(POST, "/{index}/_update/{id}")));
}

@Override
Expand All @@ -77,12 +67,7 @@ public String getName() {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
UpdateRequest updateRequest;
if (request.hasParam("type")) {
deprecationLogger.deprecate("update_with_types", TYPES_DEPRECATION_MESSAGE);
updateRequest = new UpdateRequest(request.param("index"), request.param("type"), request.param("id"));
} else {
updateRequest = new UpdateRequest(request.param("index"), request.param("id"));
}
updateRequest = new UpdateRequest(request.param("index"), request.param("id"));

updateRequest.routing(request.param("routing"));
updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout()));
Expand Down