Skip to content

Commit

Permalink
In the field capabilities API, remove support for providing fields in…
Browse files Browse the repository at this point in the history
… the request body. (#30185)
  • Loading branch information
jtibshirani authored Apr 27, 2018
1 parent 9c586a2 commit f5978d6
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 123 deletions.
2 changes: 2 additions & 0 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

<<remove-suggest-metric, Removed `suggest` metric on stats APIs>> ({pull}29635[#29635])

<<remove-field-caps-body, In field capabilities APIs, removed support for providing fields in the request body>> ({pull}30185[#30185])

=== Breaking Java Changes

=== Deprecations
Expand Down
12 changes: 0 additions & 12 deletions docs/reference/migration/migrate_6_4.asciidoc

This file was deleted.

7 changes: 7 additions & 0 deletions docs/reference/migration/migrate_7_0/api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,10 @@ Previously, `suggest` stats were folded into `search` stats. Support for the
`suggest` metric on the indices stats and nodes stats APIs remained for
backwards compatibility. Backwards support for the `suggest` metric was
deprecated in 6.3.0 and now removed in 7.0.0.

[[remove-field-caps-body]]
==== In the fields capabilities API, `fields` can no longer be provided in the request body.

In the past, `fields` could be provided either as a parameter, or as part of the request
body. Specifying `fields` in the request body as opposed to a parameter was deprecated
in 6.4.0, and is now unsupported in 7.0.0.
14 changes: 0 additions & 14 deletions docs/reference/search/field-caps.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,6 @@ GET twitter/_field_caps?fields=rating
// CONSOLE
// TEST[setup:twitter]

Alternatively the `fields` option can also be defined in the request body. deprecated[6.4.0, Please use a request parameter instead.]

[source,js]
--------------------------------------------------
POST _field_caps
{
"fields" : ["rating"]
}
--------------------------------------------------
// CONSOLE
// TEST[warning:Specifying a request body is deprecated -- the [fields] request parameter should be used instead.]

This is equivalent to the previous request.

Supported request options:

[horizontal]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
}
}
},
"body": {
"description": "Field json objects containing an array of field names",
"required": false
}
"body": null
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.common.io.stream.StreamOutput;
import org.elasticsearch.common.xcontent.ObjectParser;
import org.elasticsearch.common.xcontent.XContentParser;

import java.io.IOException;
import java.util.Arrays;
Expand Down Expand Up @@ -102,10 +101,6 @@ public void writeTo(StreamOutput out) throws IOException {
}
}

public static FieldCapabilitiesRequest parseFields(XContentParser parser) throws IOException {
return PARSER.parse(parser, null);
}

/**
* The list of field names to retrieve
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,18 @@
package org.elasticsearch.rest.action;

import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.client.node.NodeClient;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentParser;
import org.elasticsearch.rest.BaseRestHandler;
import org.elasticsearch.rest.BytesRestResponse;
import org.elasticsearch.rest.RestController;
import org.elasticsearch.rest.RestRequest;
import org.elasticsearch.rest.RestResponse;
import org.elasticsearch.rest.RestStatus;

import java.io.IOException;

import static org.elasticsearch.rest.RestRequest.Method.GET;
import static org.elasticsearch.rest.RestRequest.Method.POST;
import static org.elasticsearch.rest.RestStatus.OK;

public class RestFieldCapabilitiesAction extends BaseRestHandler {
public RestFieldCapabilitiesAction(Settings settings, RestController controller) {
Expand All @@ -57,30 +50,13 @@ public String getName() {
@Override
public RestChannelConsumer prepareRequest(final RestRequest request,
final NodeClient client) throws IOException {
if (request.hasContentOrSourceParam()) {
deprecationLogger.deprecated("Specifying a request body is deprecated -- the" +
" [fields] request parameter should be used instead.");
if (request.hasParam("fields")) {
throw new IllegalArgumentException("can't specify a request body and [fields]" +
" request parameter, either specify a request body or the" +
" [fields] request parameter");
}
}
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
FieldCapabilitiesRequest fieldRequest = new FieldCapabilitiesRequest()
.fields(Strings.splitStringByCommaToArray(request.param("fields")))
.indices(indices);

final String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
final FieldCapabilitiesRequest fieldRequest;
if (request.hasContentOrSourceParam()) {
try (XContentParser parser = request.contentOrSourceParamParser()) {
fieldRequest = FieldCapabilitiesRequest.parseFields(parser);
}
} else {
fieldRequest = new FieldCapabilitiesRequest();
fieldRequest.fields(Strings.splitStringByCommaToArray(request.param("fields")));
}
fieldRequest.indices(indices);
fieldRequest.indicesOptions(
IndicesOptions.fromRequest(request, fieldRequest.indicesOptions())
);
IndicesOptions.fromRequest(request, fieldRequest.indicesOptions()));
return channel -> client.fieldCaps(fieldRequest, new RestToXContentListener<>(channel));
}
}

This file was deleted.

0 comments on commit f5978d6

Please sign in to comment.