[Remove] Type mapping parameter from document update API (#2204)
* Remove type param from yml and integ test files Signed-off-by: Suraj Singh <surajrider@gmail.com> * Remove type mapping specific update API Signed-off-by: Suraj Singh <surajrider@gmail.com>
This commit is contained in:
parent
ac86908369
commit
52eaf96a88
|
@ -624,8 +624,7 @@ public class FullClusterRestartIT extends AbstractFullClusterRestartTestCase {
|
||||||
Map<?, ?> hit = (Map<?, ?>) ((List<?>)(XContentMapValues.extractValue("hits.hits", searchResponse))).get(0);
|
Map<?, ?> hit = (Map<?, ?>) ((List<?>)(XContentMapValues.extractValue("hits.hits", searchResponse))).get(0);
|
||||||
String docId = (String) hit.get("_id");
|
String docId = (String) hit.get("_id");
|
||||||
|
|
||||||
Request updateRequest = new Request("POST", "/" + index + "/" + typeName + "/" + docId + "/_update");
|
Request updateRequest = new Request("POST", "/" + index + "/_update/" + docId);
|
||||||
updateRequest.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
updateRequest.setJsonEntity("{ \"doc\" : { \"foo\": \"bar\"}}");
|
updateRequest.setJsonEntity("{ \"doc\" : { \"foo\": \"bar\"}}");
|
||||||
client().performRequest(updateRequest);
|
client().performRequest(updateRequest);
|
||||||
|
|
||||||
|
|
|
@ -659,7 +659,6 @@ public class RecoveryIT extends AbstractRollingTestCase {
|
||||||
for (int i = 0; i < times; i++) {
|
for (int i = 0; i < times; i++) {
|
||||||
long value = randomNonNegativeLong();
|
long value = randomNonNegativeLong();
|
||||||
Request update = new Request("POST", index + "/_update/" + docId);
|
Request update = new Request("POST", index + "/_update/" + docId);
|
||||||
update.setOptions(expectWarnings(RestUpdateAction.TYPES_DEPRECATION_MESSAGE));
|
|
||||||
update.setJsonEntity("{\"doc\": {\"updated_field\": " + value + "}}");
|
update.setJsonEntity("{\"doc\": {\"updated_field\": " + value + "}}");
|
||||||
client().performRequest(update);
|
client().performRequest(update);
|
||||||
updates.put(docId, value);
|
updates.put(docId, value);
|
||||||
|
|
|
@ -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}
|
|
|
@ -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" }
|
|
|
@ -38,7 +38,6 @@ import org.opensearch.action.index.IndexRequest;
|
||||||
import org.opensearch.action.support.ActiveShardCount;
|
import org.opensearch.action.support.ActiveShardCount;
|
||||||
import org.opensearch.action.update.UpdateRequest;
|
import org.opensearch.action.update.UpdateRequest;
|
||||||
import org.opensearch.client.node.NodeClient;
|
import org.opensearch.client.node.NodeClient;
|
||||||
import org.opensearch.common.logging.DeprecationLogger;
|
|
||||||
import org.opensearch.index.VersionType;
|
import org.opensearch.index.VersionType;
|
||||||
import org.opensearch.rest.BaseRestHandler;
|
import org.opensearch.rest.BaseRestHandler;
|
||||||
import org.opensearch.rest.RestRequest;
|
import org.opensearch.rest.RestRequest;
|
||||||
|
@ -54,19 +53,10 @@ import static java.util.Collections.unmodifiableList;
|
||||||
import static org.opensearch.rest.RestRequest.Method.POST;
|
import static org.opensearch.rest.RestRequest.Method.POST;
|
||||||
|
|
||||||
public class RestUpdateAction extends BaseRestHandler {
|
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
|
@Override
|
||||||
public List<Route> routes() {
|
public List<Route> routes() {
|
||||||
return unmodifiableList(
|
return unmodifiableList(asList(new Route(POST, "/{index}/_update/{id}")));
|
||||||
asList(
|
|
||||||
new Route(POST, "/{index}/_update/{id}"),
|
|
||||||
// Deprecated typed endpoint.
|
|
||||||
new Route(POST, "/{index}/{type}/{id}/_update")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -77,12 +67,7 @@ public class RestUpdateAction extends BaseRestHandler {
|
||||||
@Override
|
@Override
|
||||||
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
|
||||||
UpdateRequest updateRequest;
|
UpdateRequest updateRequest;
|
||||||
if (request.hasParam("type")) {
|
updateRequest = new UpdateRequest(request.param("index"), request.param("id"));
|
||||||
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.routing(request.param("routing"));
|
updateRequest.routing(request.param("routing"));
|
||||||
updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout()));
|
updateRequest.timeout(request.paramAsTime("timeout", updateRequest.timeout()));
|
||||||
|
|
Loading…
Reference in New Issue