Skip to content

Commit

Permalink
[Remove] Type mapping parameter from document update API (#2204)
Browse files Browse the repository at this point in the history
* Remove type param from yml and integ test files

Signed-off-by: Suraj Singh <[email protected]>

* Remove type mapping specific update API

Signed-off-by: Suraj Singh <[email protected]>
  • Loading branch information
dreamer-89 authored Feb 22, 2022
1 parent ac86908 commit 52eaf96
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 78 deletions.
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 @@ -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

0 comments on commit 52eaf96

Please sign in to comment.