From 59ee8b5c691bec3e7cb784c7f2f390c0a7325896 Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Mon, 3 Dec 2018 10:22:42 -0800 Subject: [PATCH] Remove the deprecated _termvector endpoint. (#36131) --- docs/reference/docs/termvectors.asciidoc | 3 - .../migration/migrate_7_0/api.asciidoc | 7 ++ .../migration/migrate_7_0/java.asciidoc | 8 ++- .../java/org/elasticsearch/client/Client.java | 33 --------- .../client/support/AbstractClient.java | 24 ------- .../document/RestTermVectorsAction.java | 16 ++--- .../action/termvectors/GetTermVectorsIT.java | 4 +- .../document/RestTermVectorsActionTests.java | 67 ------------------- .../integration/IndexPrivilegeTests.java | 4 +- 9 files changed, 22 insertions(+), 144 deletions(-) delete mode 100644 server/src/test/java/org/elasticsearch/rest/action/document/RestTermVectorsActionTests.java diff --git a/docs/reference/docs/termvectors.asciidoc b/docs/reference/docs/termvectors.asciidoc index 3cd21b21df4..11de3e5a27f 100644 --- a/docs/reference/docs/termvectors.asciidoc +++ b/docs/reference/docs/termvectors.asciidoc @@ -27,9 +27,6 @@ or by adding the requested fields in the request body (see example below). Fields can also be specified with wildcards in similar way to the <> -[WARNING] -Note that the usage of `/_termvector` is deprecated in 2.0, and replaced by `/_termvectors`. - [float] === Return values diff --git a/docs/reference/migration/migrate_7_0/api.asciidoc b/docs/reference/migration/migrate_7_0/api.asciidoc index a543ef4b054..83370a93d55 100644 --- a/docs/reference/migration/migrate_7_0/api.asciidoc +++ b/docs/reference/migration/migrate_7_0/api.asciidoc @@ -119,3 +119,10 @@ while now an exception is thrown. The deprecated graph endpoints (those with `/_graph/_explore`) have been removed. + + +[float] +==== Deprecated `_termvector` endpoint removed + +The `_termvector` endpoint was deprecated in 2.0 and has now been removed. +The endpoint `_termvectors` (plural) should be used instead. diff --git a/docs/reference/migration/migrate_7_0/java.asciidoc b/docs/reference/migration/migrate_7_0/java.asciidoc index 4357b3fa728..e48a4cf1b45 100644 --- a/docs/reference/migration/migrate_7_0/java.asciidoc +++ b/docs/reference/migration/migrate_7_0/java.asciidoc @@ -32,4 +32,10 @@ was moved to `org.elasticsearch.search.aggregations.PipelineAggregationBuilders` ==== `Retry.withBackoff` methods with `Settings` removed The variants of `Retry.withBackoff` that included `Settings` have been removed -because `Settings` is no longer needed. \ No newline at end of file +because `Settings` is no longer needed. + +[float] +==== Deprecated method `Client#termVector` removed + +The client method `termVector`, deprecated in 2.0, has been removed. The method +`termVectors` (plural) should be used instead. \ No newline at end of file diff --git a/server/src/main/java/org/elasticsearch/client/Client.java b/server/src/main/java/org/elasticsearch/client/Client.java index d2be1fba086..07871709f57 100644 --- a/server/src/main/java/org/elasticsearch/client/Client.java +++ b/server/src/main/java/org/elasticsearch/client/Client.java @@ -370,39 +370,6 @@ public interface Client extends ElasticsearchClient, Releasable { */ TermVectorsRequestBuilder prepareTermVectors(String index, String type, String id); - /** - * An action that returns the term vectors for a specific document. - * - * @param request The term vector request - * @return The response future - */ - @Deprecated - ActionFuture termVector(TermVectorsRequest request); - - /** - * An action that returns the term vectors for a specific document. - * - * @param request The term vector request - */ - @Deprecated - void termVector(TermVectorsRequest request, ActionListener listener); - - /** - * Builder for the term vector request. - */ - @Deprecated - TermVectorsRequestBuilder prepareTermVector(); - - /** - * Builder for the term vector request. - * - * @param index The index to load the document from - * @param type The type of the document - * @param id The id of the document - */ - @Deprecated - TermVectorsRequestBuilder prepareTermVector(String index, String type, String id); - /** * Multi get term vectors. */ diff --git a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java index d6ce6089017..d642101e1c3 100644 --- a/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/elasticsearch/client/support/AbstractClient.java @@ -581,30 +581,6 @@ public abstract class AbstractClient implements Client { return new TermVectorsRequestBuilder(this, TermVectorsAction.INSTANCE, index, type, id); } - @Deprecated - @Override - public ActionFuture termVector(final TermVectorsRequest request) { - return termVectors(request); - } - - @Deprecated - @Override - public void termVector(final TermVectorsRequest request, final ActionListener listener) { - termVectors(request, listener); - } - - @Deprecated - @Override - public TermVectorsRequestBuilder prepareTermVector() { - return prepareTermVectors(); - } - - @Deprecated - @Override - public TermVectorsRequestBuilder prepareTermVector(String index, String type, String id) { - return prepareTermVectors(index, type, id); - } - @Override public ActionFuture multiTermVectors(final MultiTermVectorsRequest request) { return execute(MultiTermVectorsAction.INSTANCE, request); diff --git a/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java b/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java index a312f6ab284..89b8b9267f6 100644 --- a/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java +++ b/server/src/main/java/org/elasticsearch/rest/action/document/RestTermVectorsAction.java @@ -19,11 +19,9 @@ package org.elasticsearch.rest.action.document; -import org.apache.logging.log4j.LogManager; import org.elasticsearch.action.termvectors.TermVectorsRequest; import org.elasticsearch.client.node.NodeClient; import org.elasticsearch.common.Strings; -import org.elasticsearch.common.logging.DeprecationLogger; import org.elasticsearch.common.settings.Settings; import org.elasticsearch.common.xcontent.XContentParser; import org.elasticsearch.index.VersionType; @@ -45,19 +43,13 @@ import static org.elasticsearch.rest.RestRequest.Method.POST; * TermVectorsRequest. */ public class RestTermVectorsAction extends BaseRestHandler { - private static final DeprecationLogger deprecationLogger = new DeprecationLogger( - LogManager.getLogger(RestTermVectorsAction.class)); public RestTermVectorsAction(Settings settings, RestController controller) { super(settings); - controller.registerWithDeprecatedHandler(GET, "/{index}/{type}/_termvectors", this, - GET, "/{index}/{type}/_termvector", deprecationLogger); - controller.registerWithDeprecatedHandler(POST, "/{index}/{type}/_termvectors", this, - POST, "/{index}/{type}/_termvector", deprecationLogger); - controller.registerWithDeprecatedHandler(GET, "/{index}/{type}/{id}/_termvectors", this, - GET, "/{index}/{type}/{id}/_termvector", deprecationLogger); - controller.registerWithDeprecatedHandler(POST, "/{index}/{type}/{id}/_termvectors", this, - POST, "/{index}/{type}/{id}/_termvector", deprecationLogger); + controller.registerHandler(GET, "/{index}/{type}/_termvectors", this); + controller.registerHandler(POST, "/{index}/{type}/_termvectors", this); + controller.registerHandler(GET, "/{index}/{type}/{id}/_termvectors", this); + controller.registerHandler(POST, "/{index}/{type}/{id}/_termvectors", this); } @Override diff --git a/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java b/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java index a45012dc4b3..442e27c0867 100644 --- a/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java +++ b/server/src/test/java/org/elasticsearch/action/termvectors/GetTermVectorsIT.java @@ -506,7 +506,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { for (int id = 0; id < content.length; id++) { Fields[] fields = new Fields[2]; for (int j = 0; j < indexNames.length; j++) { - TermVectorsResponse resp = client().prepareTermVector(indexNames[j], "type1", String.valueOf(id)) + TermVectorsResponse resp = client().prepareTermVectors(indexNames[j], "type1", String.valueOf(id)) .setOffsets(true) .setPositions(true) .setSelectedFields("field1") @@ -1069,7 +1069,7 @@ public class GetTermVectorsIT extends AbstractTermVectorsTestCase { for (int id = 0; id < content.length; id++) { Fields[] fields = new Fields[2]; for (int j = 0; j < indexNames.length; j++) { - TermVectorsResponse resp = client().prepareTermVector(indexNames[j], "type1", String.valueOf(id)) + TermVectorsResponse resp = client().prepareTermVectors(indexNames[j], "type1", String.valueOf(id)) .setOffsets(true) .setPositions(true) .setSelectedFields("field1", "field2") diff --git a/server/src/test/java/org/elasticsearch/rest/action/document/RestTermVectorsActionTests.java b/server/src/test/java/org/elasticsearch/rest/action/document/RestTermVectorsActionTests.java deleted file mode 100644 index 88c867b0e56..00000000000 --- a/server/src/test/java/org/elasticsearch/rest/action/document/RestTermVectorsActionTests.java +++ /dev/null @@ -1,67 +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.document; - -import org.elasticsearch.client.node.NodeClient; -import org.elasticsearch.common.settings.Settings; -import org.elasticsearch.common.util.concurrent.ThreadContext; -import org.elasticsearch.indices.breaker.NoneCircuitBreakerService; -import org.elasticsearch.rest.RestChannel; -import org.elasticsearch.rest.RestController; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.rest.RestRequest.Method; -import org.elasticsearch.test.ESTestCase; -import org.elasticsearch.test.rest.FakeRestChannel; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.usage.UsageService; - -import java.util.Collections; - -import static org.mockito.Mockito.mock; - -public class RestTermVectorsActionTests extends ESTestCase { - private RestController controller; - - public void setUp() throws Exception { - super.setUp(); - controller = new RestController(Collections.emptySet(), null, - mock(NodeClient.class), - new NoneCircuitBreakerService(), - new UsageService()); - new RestTermVectorsAction(Settings.EMPTY, controller); - } - - public void testDeprecatedEndpoint() { - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(Method.POST) - .withPath("/some_index/some_type/some_id/_termvector") - .build(); - - performRequest(request); - assertWarnings("[POST /{index}/{type}/{id}/_termvector] is deprecated! Use" + - " [POST /{index}/{type}/{id}/_termvectors] instead."); - } - - private void performRequest(RestRequest request) { - RestChannel channel = new FakeRestChannel(request, false, 1); - ThreadContext threadContext = new ThreadContext(Settings.EMPTY); - controller.dispatchRequest(request, channel, threadContext); - } -} diff --git a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java index ed82808af76..f1f3993261e 100644 --- a/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java +++ b/x-pack/plugin/security/src/test/java/org/elasticsearch/integration/IndexPrivilegeTests.java @@ -492,13 +492,13 @@ public class IndexPrivilegeTests extends AbstractPrivilegeTestCase { assertAccessIsAllowed("admin", "GET", "/" + index + "/_search"); assertAccessIsAllowed("admin", "GET", "/" + index + "/foo/1"); assertAccessIsAllowed(user, "GET", "/" + index + "/foo/1/_explain", "{ \"query\" : { \"match_all\" : {} } }"); - assertAccessIsAllowed(user, "GET", "/" + index + "/foo/1/_termvector"); + assertAccessIsAllowed(user, "GET", "/" + index + "/foo/1/_termvectors"); assertUserIsAllowed(user, "search", index); } else { assertAccessIsDenied(user, "GET", "/" + index + "/_count"); assertAccessIsDenied(user, "GET", "/" + index + "/_search"); assertAccessIsDenied(user, "GET", "/" + index + "/foo/1/_explain", "{ \"query\" : { \"match_all\" : {} } }"); - assertAccessIsDenied(user, "GET", "/" + index + "/foo/1/_termvector"); + assertAccessIsDenied(user, "GET", "/" + index + "/foo/1/_termvectors"); assertUserIsDenied(user, "search", index); } break;