Skip to content

Commit

Permalink
Revert "Revert removal of typed end-points for bulk, search, index AP…
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-89 committed Jun 10, 2022
1 parent a20cd3e commit 3ba56ca
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,7 @@ public RestBulkAction(Settings settings) {
@Override
public List<Route> routes() {
return unmodifiableList(
asList(
new Route(POST, "/_bulk"),
new Route(PUT, "/_bulk"),
new Route(POST, "/{index}/_bulk"),
new Route(PUT, "/{index}/_bulk"),
// Deprecated typed endpoints.
new Route(POST, "/{index}/{type}/_bulk"),
new Route(PUT, "/{index}/{type}/_bulk")
)
asList(new Route(POST, "/_bulk"), new Route(PUT, "/_bulk"), new Route(POST, "/{index}/_bulk"), new Route(PUT, "/{index}/_bulk"))
);
}

Expand All @@ -95,9 +87,6 @@ public String getName() {
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
BulkRequest bulkRequest = Requests.bulkRequest();
String defaultIndex = request.param("index");
if (request.hasParam("type")) {
request.param("type");
}
String defaultRouting = request.param("routing");
FetchSourceContext defaultFetchSourceContext = FetchSourceContext.parseFromRestRequest(request);
String defaultPipeline = request.param("pipeline");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ public class RestDeleteAction extends BaseRestHandler {

@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}")));
}

@Override
Expand All @@ -73,9 +67,6 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.hasParam("type")) {
request.param("type");
}
DeleteRequest 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 @@ -63,14 +63,7 @@ public class RestIndexAction extends BaseRestHandler {

@Override
public List<Route> routes() {
return unmodifiableList(
asList(
new Route(POST, "/{index}/_doc/{id}"),
new Route(PUT, "/{index}/_doc/{id}"),
new Route(POST, "/{index}/{type}/{id}"),
new Route(PUT, "/{index}/{type}/{id}")
)
);
return unmodifiableList(asList(new Route(POST, "/{index}/_doc/{id}"), new Route(PUT, "/{index}/_doc/{id}")));
}

@Override
Expand All @@ -92,14 +85,7 @@ public String getName() {

@Override
public List<Route> routes() {
return unmodifiableList(
asList(
new Route(POST, "/{index}/_create/{id}"),
new Route(PUT, "/{index}/_create/{id}"),
new Route(POST, "/{index}/{type}/{id}/_create"),
new Route(PUT, "/{index}/{type}/{id}/_create")
)
);
return unmodifiableList(asList(new Route(POST, "/{index}/_create/{id}"), new Route(PUT, "/{index}/_create/{id}")));
}

@Override
Expand Down Expand Up @@ -136,7 +122,7 @@ public String getName() {

@Override
public List<Route> routes() {
return unmodifiableList(asList(new Route(POST, "/{index}/_doc"), new Route(POST, "/{index}/{type}")));
return unmodifiableList(asList(new Route(POST, "/{index}/_doc")));
}

@Override
Expand All @@ -153,9 +139,6 @@ public RestChannelConsumer prepareRequest(RestRequest request, final NodeClient
@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
IndexRequest indexRequest = new IndexRequest(request.param("index"));
if (request.hasParam("type")) {
request.param("type");
}
indexRequest.id(request.param("id"));
indexRequest.routing(request.param("routing"));
indexRequest.setPipeline(request.param("pipeline"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ public List<Route> routes() {
new Route(GET, "/_count"),
new Route(POST, "/_count"),
new Route(GET, "/{index}/_count"),
new Route(POST, "/{index}/_count"),
// Deprecated typed endpoints.
new Route(GET, "/{index}/{type}/_count"),
new Route(POST, "/{index}/{type}/_count")
new Route(POST, "/{index}/_count")
)
);
}
Expand All @@ -86,9 +83,6 @@ public String getName() {

@Override
public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException {
if (request.hasParam("type")) {
request.param("type");
}
SearchRequest countRequest = new SearchRequest(Strings.splitStringByCommaToArray(request.param("index")));
countRequest.indicesOptions(IndicesOptions.fromRequest(request, countRequest.indicesOptions()));
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder().size(0).trackTotalHits(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,7 @@ public List<Route> routes() {
new Route(GET, "/_search"),
new Route(POST, "/_search"),
new Route(GET, "/{index}/_search"),
new Route(POST, "/{index}/_search"),
// Deprecated typed endpoints.
new Route(GET, "/{index}/{type}/_search"),
new Route(POST, "/{index}/{type}/_search")
new Route(POST, "/{index}/_search")
)
);
}
Expand Down Expand Up @@ -200,10 +197,6 @@ public static void parseSearchRequest(
searchRequest.scroll(new Scroll(parseTimeValue(scroll, null, "scroll")));
}

if (request.hasParam("type")) {
request.param("type");
}

searchRequest.routing(request.param("routing"));
searchRequest.preference(request.param("preference"));
searchRequest.indicesOptions(IndicesOptions.fromRequest(request, searchRequest.indicesOptions()));
Expand Down

0 comments on commit 3ba56ca

Please sign in to comment.