mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-08 22:14:59 +00:00
In the field capabilities API, remove support for providing fields in the request body. (#30185)
This commit is contained in:
parent
9c586a2f07
commit
f5978d6d33
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
<<remove-suggest-metric, Removed `suggest` metric on stats APIs>> ({pull}29635[#29635])
|
<<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
|
=== Breaking Java Changes
|
||||||
|
|
||||||
=== Deprecations
|
=== Deprecations
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
[[breaking-changes-6.4]]
|
|
||||||
== Breaking changes in 6.4
|
|
||||||
|
|
||||||
[[breaking_64_api_changes]]
|
|
||||||
=== API changes
|
|
||||||
|
|
||||||
==== Field capabilities request format
|
|
||||||
|
|
||||||
In the past, `fields` could be provided either as a parameter, or as part of the request
|
|
||||||
body. Specifying `fields` in the request body is now deprecated, and instead they should
|
|
||||||
always be supplied through a request parameter. In 7.0.0, the field capabilities API will
|
|
||||||
not accept `fields` supplied in the request body.
|
|
@ -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
|
`suggest` metric on the indices stats and nodes stats APIs remained for
|
||||||
backwards compatibility. Backwards support for the `suggest` metric was
|
backwards compatibility. Backwards support for the `suggest` metric was
|
||||||
deprecated in 6.3.0 and now removed in 7.0.0.
|
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.
|
||||||
|
@ -20,20 +20,6 @@ GET twitter/_field_caps?fields=rating
|
|||||||
// CONSOLE
|
// CONSOLE
|
||||||
// TEST[setup:twitter]
|
// 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:
|
Supported request options:
|
||||||
|
|
||||||
[horizontal]
|
[horizontal]
|
||||||
|
@ -35,9 +35,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"body": {
|
"body": null
|
||||||
"description": "Field json objects containing an array of field names",
|
|
||||||
"required": false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,7 +30,6 @@ import org.elasticsearch.common.Strings;
|
|||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ObjectParser;
|
import org.elasticsearch.common.xcontent.ObjectParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -102,10 +101,6 @@ public final class FieldCapabilitiesRequest extends ActionRequest implements Ind
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FieldCapabilitiesRequest parseFields(XContentParser parser) throws IOException {
|
|
||||||
return PARSER.parse(parser, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The list of field names to retrieve
|
* The list of field names to retrieve
|
||||||
*/
|
*/
|
||||||
|
@ -20,25 +20,18 @@
|
|||||||
package org.elasticsearch.rest.action;
|
package org.elasticsearch.rest.action;
|
||||||
|
|
||||||
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
|
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesRequest;
|
||||||
import org.elasticsearch.action.fieldcaps.FieldCapabilitiesResponse;
|
|
||||||
import org.elasticsearch.action.support.IndicesOptions;
|
import org.elasticsearch.action.support.IndicesOptions;
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
import org.elasticsearch.client.node.NodeClient;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
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.BaseRestHandler;
|
||||||
import org.elasticsearch.rest.BytesRestResponse;
|
|
||||||
import org.elasticsearch.rest.RestController;
|
import org.elasticsearch.rest.RestController;
|
||||||
import org.elasticsearch.rest.RestRequest;
|
import org.elasticsearch.rest.RestRequest;
|
||||||
import org.elasticsearch.rest.RestResponse;
|
|
||||||
import org.elasticsearch.rest.RestStatus;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
import static org.elasticsearch.rest.RestRequest.Method.GET;
|
||||||
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
import static org.elasticsearch.rest.RestRequest.Method.POST;
|
||||||
import static org.elasticsearch.rest.RestStatus.OK;
|
|
||||||
|
|
||||||
public class RestFieldCapabilitiesAction extends BaseRestHandler {
|
public class RestFieldCapabilitiesAction extends BaseRestHandler {
|
||||||
public RestFieldCapabilitiesAction(Settings settings, RestController controller) {
|
public RestFieldCapabilitiesAction(Settings settings, RestController controller) {
|
||||||
@ -57,30 +50,13 @@ public class RestFieldCapabilitiesAction extends BaseRestHandler {
|
|||||||
@Override
|
@Override
|
||||||
public RestChannelConsumer prepareRequest(final RestRequest request,
|
public RestChannelConsumer prepareRequest(final RestRequest request,
|
||||||
final NodeClient client) throws IOException {
|
final NodeClient client) throws IOException {
|
||||||
if (request.hasContentOrSourceParam()) {
|
String[] indices = Strings.splitStringByCommaToArray(request.param("index"));
|
||||||
deprecationLogger.deprecated("Specifying a request body is deprecated -- the" +
|
FieldCapabilitiesRequest fieldRequest = new FieldCapabilitiesRequest()
|
||||||
" [fields] request parameter should be used instead.");
|
.fields(Strings.splitStringByCommaToArray(request.param("fields")))
|
||||||
if (request.hasParam("fields")) {
|
.indices(indices);
|
||||||
throw new IllegalArgumentException("can't specify a request body and [fields]" +
|
|
||||||
" request parameter, either specify a request body or the" +
|
|
||||||
" [fields] request parameter");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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(
|
fieldRequest.indicesOptions(
|
||||||
IndicesOptions.fromRequest(request, fieldRequest.indicesOptions())
|
IndicesOptions.fromRequest(request, fieldRequest.indicesOptions()));
|
||||||
);
|
|
||||||
return channel -> client.fieldCaps(fieldRequest, new RestToXContentListener<>(channel));
|
return channel -> client.fieldCaps(fieldRequest, new RestToXContentListener<>(channel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Licensed to Elasticsearch under one or more contributor
|
|
||||||
* license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright
|
|
||||||
* ownership. Elasticsearch licenses this file to you under
|
|
||||||
* the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
* not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.elasticsearch.rest.action;
|
|
||||||
|
|
||||||
import org.elasticsearch.client.node.NodeClient;
|
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
|
||||||
import org.elasticsearch.common.settings.Settings;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
|
||||||
import org.elasticsearch.rest.RestController;
|
|
||||||
import org.elasticsearch.rest.RestRequest;
|
|
||||||
import org.elasticsearch.rest.action.RestFieldCapabilitiesAction;
|
|
||||||
import org.elasticsearch.test.ESTestCase;
|
|
||||||
import org.elasticsearch.test.rest.FakeRestRequest;
|
|
||||||
import org.elasticsearch.usage.UsageService;
|
|
||||||
import org.junit.Before;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
public class RestFieldCapabilitiesActionTests extends ESTestCase {
|
|
||||||
|
|
||||||
private RestFieldCapabilitiesAction action;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void setUpAction() {
|
|
||||||
action = new RestFieldCapabilitiesAction(Settings.EMPTY, mock(RestController.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void testRequestBodyIsDeprecated() throws IOException {
|
|
||||||
String content = "{ \"fields\": [\"title\"] }";
|
|
||||||
RestRequest request = new FakeRestRequest.Builder(xContentRegistry())
|
|
||||||
.withPath("/_field_caps")
|
|
||||||
.withContent(new BytesArray(content), XContentType.JSON)
|
|
||||||
.build();
|
|
||||||
action.prepareRequest(request, mock(NodeClient.class));
|
|
||||||
|
|
||||||
assertWarnings("Specifying a request body is deprecated -- the" +
|
|
||||||
" [fields] request parameter should be used instead.");
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user