From 74e1c2e0db8441390e80f35adf2f5423417491eb Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Mon, 31 Jan 2022 14:59:12 -0800 Subject: [PATCH 1/4] Remove type param from yml and integ test files Signed-off-by: Suraj Singh --- .../test/count/11_basic_with_types.yml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml new file mode 100644 index 0000000000000..09d96670f688e --- /dev/null +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml @@ -0,0 +1,61 @@ +setup: + - do: + indices.create: + index: test + - do: + index: + index: test + id: 1 + body: { foo: bar } + + - do: + indices.refresh: + index: [test] + +--- +"count with body": + - do: + count: + index: test + body: + query: + match: + foo: bar + + - match: {count : 1} + + - do: + count: + index: test + body: + query: + match: + foo: test + + - match: {count : 0} + +--- +"count with empty body": +# empty body should default to match_all query + - do: + count: + index: test + body: { } + + - match: {count : 1} + + - do: + count: + index: test + + - match: {count : 1} + +--- +"count body without query element": + - do: + catch: bad_request + count: + index: test + body: + match: + foo: bar From 61973843f23f271a5a4fe22defdd9c577111a3c6 Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Tue, 1 Feb 2022 10:58:50 -0800 Subject: [PATCH 2/4] Remove type mapping specific update API Signed-off-by: Suraj Singh --- .../upgrades/FullClusterRestartIT.java | 3 +- .../org/opensearch/upgrades/RecoveryIT.java | 1 - .../test/bulk/70_mix_typeless_typeful.yml | 35 ----------- .../test/count/11_basic_with_types.yml | 61 ------------------- .../70_mix_typeless_typeful.yml | 23 ------- .../action/document/RestUpdateAction.java | 19 +----- 6 files changed, 3 insertions(+), 139 deletions(-) delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml delete mode 100644 rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_mix_typeless_typeful.yml diff --git a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java index ee903dc0f2e59..476cd2b035d63 100644 --- a/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java +++ b/qa/full-cluster-restart/src/test/java/org/opensearch/upgrades/FullClusterRestartIT.java @@ -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); diff --git a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java index 0354c23618525..1c1e3de7eae7d 100644 --- a/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java +++ b/qa/rolling-upgrade/src/test/java/org/opensearch/upgrades/RecoveryIT.java @@ -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); diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml deleted file mode 100644 index cad0891b21e52..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/bulk/70_mix_typeless_typeful.yml +++ /dev/null @@ -1,35 +0,0 @@ ---- -"bulk without types on an index that has types": - - - skip: - version: " - 6.99.99" - reason: Typeless APIs were introduced in 7.0.0 - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - do: - bulk: - refresh: true - body: - - index: - _index: index - _id: 0 - - foo: bar - - index: - _index: index - _id: 1 - - foo: bar - - - do: - count: - index: index - - - match: {count: 2} diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml deleted file mode 100644 index 09d96670f688e..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/count/11_basic_with_types.yml +++ /dev/null @@ -1,61 +0,0 @@ -setup: - - do: - indices.create: - index: test - - do: - index: - index: test - id: 1 - body: { foo: bar } - - - do: - indices.refresh: - index: [test] - ---- -"count with body": - - do: - count: - index: test - body: - query: - match: - foo: bar - - - match: {count : 1} - - - do: - count: - index: test - body: - query: - match: - foo: test - - - match: {count : 0} - ---- -"count with empty body": -# empty body should default to match_all query - - do: - count: - index: test - body: { } - - - match: {count : 1} - - - do: - count: - index: test - - - match: {count : 1} - ---- -"count body without query element": - - do: - catch: bad_request - count: - index: test - body: - match: - foo: bar diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_mix_typeless_typeful.yml b/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_mix_typeless_typeful.yml deleted file mode 100644 index 162a8d340d48a..0000000000000 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/indices.get_mapping/70_mix_typeless_typeful.yml +++ /dev/null @@ -1,23 +0,0 @@ ---- -"GET mapping with typeless API on an index that has types": - - - skip: - version: " - 6.99.99" - reason: include_type_name was introduced in 7.0.0 - - - do: - indices.create: # not using include_type_name: false on purpose - include_type_name: true - index: index - body: - mappings: - not_doc: - properties: - foo: - type: "keyword" - - - do: - indices.get_mapping: - index: index - - - match: { index.mappings.properties.foo.type: "keyword" } diff --git a/server/src/main/java/org/opensearch/rest/action/document/RestUpdateAction.java b/server/src/main/java/org/opensearch/rest/action/document/RestUpdateAction.java index 7afb0b6cba87c..832d8da4a8fdd 100644 --- a/server/src/main/java/org/opensearch/rest/action/document/RestUpdateAction.java +++ b/server/src/main/java/org/opensearch/rest/action/document/RestUpdateAction.java @@ -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; @@ -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 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 @@ -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())); From 449b5ecb0b76e70d92b6e4446ac36d45013e6bda Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Tue, 1 Feb 2022 13:53:27 -0800 Subject: [PATCH 3/4] Remove type mapping specific delete API Signed-off-by: Suraj Singh --- .../rest/action/document/RestDeleteAction.java | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java b/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java index 25a50a49d3aa0..716a14182fee2 100644 --- a/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java @@ -56,13 +56,7 @@ public class RestDeleteAction extends BaseRestHandler { @Override public List 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}"))); } @Override @@ -73,12 +67,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)); From af794002856b770b6a099960b46278a268599c1f Mon Sep 17 00:00:00 2001 From: Suraj Singh Date: Tue, 22 Feb 2022 11:25:01 -0800 Subject: [PATCH 4/4] Address review comments Signed-off-by: Suraj Singh --- .../opensearch/rest/action/document/RestDeleteAction.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java b/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java index 716a14182fee2..a7331ec882ad2 100644 --- a/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java +++ b/server/src/main/java/org/opensearch/rest/action/document/RestDeleteAction.java @@ -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; @@ -50,13 +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 routes() { - return unmodifiableList(asList(new Route(DELETE, "/{index}/_doc/{id}"))); + return unmodifiableList(asList(new Route(DELETE, "/{index}/_doc/{id}"), new Route(DELETE, "/{index}/{id}"))); } @Override