diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java index 69a70bd97f17a..48009810cf3b0 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/GraphRequestConverters.java @@ -29,7 +29,7 @@ final class GraphRequestConverters { private GraphRequestConverters() {} static Request explore(GraphExploreRequest exploreRequest) throws IOException { - String endpoint = RequestConverters.endpoint(exploreRequest.indices(), exploreRequest.types(), "_graph/explore"); + String endpoint = RequestConverters.endpoint(exploreRequest.indices(), "_graph/explore"); Request request = new Request(HttpGet.METHOD_NAME, endpoint); request.setEntity(RequestConverters.createEntity(exploreRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); return request; diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java index 5a0a4c2a92089..c3230a75a58de 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/graph/GraphExploreRequest.java @@ -47,7 +47,6 @@ public class GraphExploreRequest implements IndicesRequest.Replaceable, ToXConte public static final String NO_VERTICES_ERROR_MESSAGE = "Graph explore hop must have at least one VertexRequest"; private String[] indices = Strings.EMPTY_ARRAY; private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false); - private String[] types = Strings.EMPTY_ARRAY; private String routing; private TimeValue timeout; @@ -106,31 +105,6 @@ public GraphExploreRequest indicesOptions(IndicesOptions indicesOptions) { return this; } - /** - * The document types to execute the explore against. Defaults to be executed against - * all types. - * - * @deprecated Types are in the process of being removed. Instead of using a type, prefer to - * filter on a field on the document. - */ - @Deprecated - public String[] types() { - return this.types; - } - - /** - * The document types to execute the explore request against. Defaults to be executed against - * all types. - * - * @deprecated Types are in the process of being removed. Instead of using a type, prefer to - * filter on a field on the document. - */ - @Deprecated - public GraphExploreRequest types(String... types) { - this.types = types; - return this; - } - public String routing() { return this.routing; } @@ -154,7 +128,7 @@ public TimeValue timeout() { * operations involved in each hop are limited to the remaining time * available but can still overrun due to the nature of their "best efforts" * timeout support. When a timeout occurs partial results are returned. - * + * * @param timeout * a {@link TimeValue} object which determines the maximum length * of time to spend exploring @@ -174,7 +148,7 @@ public GraphExploreRequest timeout(String timeout) { @Override public String toString() { - return "graph explore [" + Arrays.toString(indices) + "][" + Arrays.toString(types) + "]"; + return "graph explore [" + Arrays.toString(indices) + "]"; } /** @@ -190,7 +164,7 @@ public String toString() { * better with smaller samples as there are less look-ups required for * background frequencies of terms found in the documents *

- * + * * @param maxNumberOfDocsPerHop * shard-level sample size in documents */ @@ -231,7 +205,7 @@ public int maxDocsPerDiversityValue() { * default value is true which means terms are selected based on * significance (see the {@link SignificantTerms} aggregation) rather than * popularity (using the {@link TermsAggregator}). - * + * * @param value * true if the significant_terms algorithm should be used. */ @@ -246,7 +220,7 @@ public boolean useSignificance() { /** * Return detailed information about vertex frequencies as part of JSON * results - defaults to false - * + * * @param value * true if detailed information is required in JSON responses */ @@ -262,7 +236,7 @@ public boolean returnDetailedInfo() { * Add a stage in the graph exploration. Each hop represents a stage of * querying elasticsearch to identify terms which can then be connnected to * other terms in a subsequent hop. - * + * * @param guidingQuery * optional choice of query which influences which documents are * considered in this stage @@ -316,7 +290,7 @@ public float getBoost() { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - + builder.startObject("controls"); { if (sampleSize != SamplerAggregationBuilder.DEFAULT_SHARD_SAMPLE_SIZE) { diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/GraphRequestConvertersTests.java similarity index 93% rename from client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java rename to client/rest-high-level/src/test/java/org/elasticsearch/client/GraphRequestConvertersTests.java index 7c653bdee384d..c45552f0debfc 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/GrapRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/GraphRequestConvertersTests.java @@ -33,7 +33,7 @@ import static org.hamcrest.Matchers.is; -public class GrapRequestConvertersTests extends ESTestCase { +public class GraphRequestConvertersTests extends ESTestCase { public void testGraphExplore() throws Exception { Map expectedParams = new HashMap<>(); @@ -41,7 +41,6 @@ public void testGraphExplore() throws Exception { GraphExploreRequest graphExploreRequest = new GraphExploreRequest(); graphExploreRequest.sampleDiversityField("diversity"); graphExploreRequest.indices("index1", "index2"); - graphExploreRequest.types("type1", "type2"); int timeout = randomIntBetween(10000, 20000); graphExploreRequest.timeout(TimeValue.timeValueMillis(timeout)); graphExploreRequest.useSignificance(randomBoolean()); @@ -58,7 +57,7 @@ public void testGraphExplore() throws Exception { } Request request = GraphRequestConverters.explore(graphExploreRequest); assertEquals(HttpGet.METHOD_NAME, request.getMethod()); - assertEquals("/index1,index2/type1,type2/_graph/explore", request.getEndpoint()); + assertEquals("/index1,index2/_graph/explore", request.getEndpoint()); assertEquals(expectedParams, request.getParameters()); assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters())); RequestConvertersTests.assertToXContentBody(graphExploreRequest, request.getEntity()); diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java index 29c831438f906..1d8230348326b 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/protocol/xpack/graph/GraphExploreRequest.java @@ -5,6 +5,7 @@ */ package org.elasticsearch.protocol.xpack.graph; +import org.elasticsearch.Version; import org.elasticsearch.action.ActionRequest; import org.elasticsearch.action.ActionRequestValidationException; import org.elasticsearch.action.IndicesRequest; @@ -24,7 +25,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; /** @@ -37,7 +37,6 @@ public class GraphExploreRequest extends ActionRequest implements IndicesRequest public static final String NO_VERTICES_ERROR_MESSAGE = "Graph explore hop must have at least one VertexRequest"; private String[] indices = Strings.EMPTY_ARRAY; private IndicesOptions indicesOptions = IndicesOptions.fromOptions(false, false, true, false); - private String[] types = Strings.EMPTY_ARRAY; private String routing; private TimeValue timeout; @@ -96,37 +95,15 @@ public GraphExploreRequest indicesOptions(IndicesOptions indicesOptions) { return this; } - /** - * The document types to execute the explore against. Defaults to be executed against - * all types. - * - * @deprecated Types are in the process of being removed. Instead of using a type, prefer to - * filter on a field on the document. - */ - @Deprecated - public String[] types() { - return this.types; - } - - /** - * The document types to execute the explore request against. Defaults to be executed against - * all types. - * - * @deprecated Types are in the process of being removed. Instead of using a type, prefer to - * filter on a field on the document. - */ - @Deprecated - public GraphExploreRequest types(String... types) { - this.types = types; - return this; - } - public GraphExploreRequest(StreamInput in) throws IOException { super(in); indices = in.readStringArray(); indicesOptions = IndicesOptions.readIndicesOptions(in); - types = in.readStringArray(); + if (in.getVersion().before(Version.V_8_0_0)) { + String[] types = in.readStringArray(); + assert types.length == 0; + } routing = in.readOptionalString(); timeout = in.readOptionalTimeValue(); sampleSize = in.readInt(); @@ -169,7 +146,7 @@ public TimeValue timeout() { * operations involved in each hop are limited to the remaining time * available but can still overrun due to the nature of their "best efforts" * timeout support. When a timeout occurs partial results are returned. - * + * * @param timeout * a {@link TimeValue} object which determines the maximum length * of time to spend exploring @@ -192,7 +169,9 @@ public void writeTo(StreamOutput out) throws IOException { super.writeTo(out); out.writeStringArray(indices); indicesOptions.writeIndicesOptions(out); - out.writeStringArray(types); + if (out.getVersion().before(Version.V_8_0_0)) { + out.writeStringArray(Strings.EMPTY_ARRAY); + } out.writeOptionalString(routing); out.writeOptionalTimeValue(timeout); @@ -203,15 +182,14 @@ public void writeTo(StreamOutput out) throws IOException { out.writeBoolean(useSignificance); out.writeBoolean(returnDetailedInfo); out.writeInt(hops.size()); - for (Iterator iterator = hops.iterator(); iterator.hasNext();) { - Hop hop = iterator.next(); + for (Hop hop : hops) { hop.writeTo(out); } } @Override public String toString() { - return "graph explore [" + Arrays.toString(indices) + "][" + Arrays.toString(types) + "]"; + return "graph explore [" + Arrays.toString(indices) + "]"; } /** @@ -227,7 +205,7 @@ public String toString() { * better with smaller samples as there are less look-ups required for * background frequencies of terms found in the documents *

- * + * * @param maxNumberOfDocsPerHop * shard-level sample size in documents */ @@ -268,7 +246,7 @@ public int maxDocsPerDiversityValue() { * default value is true which means terms are selected based on * significance (see the {@link SignificantTerms} aggregation) rather than * popularity (using the {@link TermsAggregator}). - * + * * @param value * true if the significant_terms algorithm should be used. */ @@ -283,7 +261,7 @@ public boolean useSignificance() { /** * Return detailed information about vertex frequencies as part of JSON * results - defaults to false - * + * * @param value * true if detailed information is required in JSON responses */ @@ -299,7 +277,7 @@ public boolean returnDetailedInfo() { * Add a stage in the graph exploration. Each hop represents a stage of * querying elasticsearch to identify terms which can then be connnected to * other terms in a subsequent hop. - * + * * @param guidingQuery * optional choice of query which influences which documents are * considered in this stage @@ -364,7 +342,7 @@ void writeTo(StreamOutput out) throws IOException { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { builder.startObject(); - + builder.startObject("controls"); { if (sampleSize != SamplerAggregationBuilder.DEFAULT_SHARD_SAMPLE_SIZE) { diff --git a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreRequestBuilder.java b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreRequestBuilder.java index 37456f234648a..38e02be2656b7 100644 --- a/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreRequestBuilder.java +++ b/x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/graph/action/GraphExploreRequestBuilder.java @@ -20,7 +20,7 @@ /** * Creates a new {@link GraphExploreRequestBuilder} - * + * * @see GraphExploreRequest */ public class GraphExploreRequestBuilder extends ActionRequestBuilder { @@ -106,16 +106,7 @@ public GraphExploreRequestBuilder setTimeout(String timeout) { } /** - * The types of documents the graph exploration will run against. Defaults - * to all types. - */ - public GraphExploreRequestBuilder setTypes(String... types) { - request.types(types); - return this; - } - - /** - * Add a stage in the graph exploration. Each hop represents a stage of + * Add a stage in the graph exploration. Each hop represents a stage of * querying elasticsearch to identify terms which can then be connnected * to other terms in a subsequent hop. * @param guidingQuery optional choice of query which influences which documents @@ -129,7 +120,7 @@ public Hop createNextHop(@Nullable QueryBuilder guidingQuery) { /** * Controls the choice of algorithm used to select interesting terms. The default * value is true which means terms are selected based on significance (see the {@link SignificantTerms} - * aggregation) rather than popularity (using the {@link TermsAggregator}). + * aggregation) rather than popularity (using the {@link TermsAggregator}). * @param value true if the significant_terms algorithm should be used. */ public GraphExploreRequestBuilder useSignificance(boolean value) { @@ -137,19 +128,19 @@ public GraphExploreRequestBuilder useSignificance(boolean value) { return this; } - + /** - * The number of top-matching documents that are considered during each hop (default is + * The number of top-matching documents that are considered during each hop (default is * {@link SamplerAggregationBuilder#DEFAULT_SHARD_SAMPLE_SIZE} * Very small values (less than 50) may not provide sufficient weight-of-evidence to identify - * significant connections between terms. - *

Very large values (many thousands) are not recommended with loosely defined queries (fuzzy queries or + * significant connections between terms. + *

Very large values (many thousands) are not recommended with loosely defined queries (fuzzy queries or * those with many OR clauses). * This is because any useful signals in the best documents are diluted with irrelevant noise from low-quality matches. - * Performance is also typically better with smaller samples as there are less look-ups required for background frequencies - * of terms found in the documents + * Performance is also typically better with smaller samples as there are less look-ups required for background frequencies + * of terms found in the documents *

- * + * * @param maxNumberOfDocsPerHop the shard-level sample size in documents */ public GraphExploreRequestBuilder sampleSize(int maxNumberOfDocsPerHop) { diff --git a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java index b4cad83951537..40331f168c2d3 100644 --- a/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java +++ b/x-pack/plugin/graph/src/main/java/org/elasticsearch/xpack/graph/rest/action/RestGraphAction.java @@ -40,8 +40,6 @@ public class RestGraphAction extends BaseRestHandler { private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGraphAction.class)); - public static final String TYPES_DEPRECATION_MESSAGE = "[types removal]" + - " Specifying types in graph requests is deprecated."; public static final ParseField TIMEOUT_FIELD = new ParseField("timeout"); public static final ParseField SIGNIFICANCE_FIELD = new ParseField("use_significance"); @@ -65,20 +63,12 @@ public class RestGraphAction extends BaseRestHandler { public RestGraphAction(RestController controller) { // TODO: remove deprecated endpoint in 8.0.0 controller.registerWithDeprecatedHandler( - GET, "/{index}/_graph/explore", this, - GET, "/{index}/_xpack/graph/_explore", deprecationLogger); + GET, "/{index}/_graph/explore", this, + GET, "/{index}/_xpack/graph/_explore", deprecationLogger); // TODO: remove deprecated endpoint in 8.0.0 controller.registerWithDeprecatedHandler( - POST, "/{index}/_graph/explore", this, - POST, "/{index}/_xpack/graph/_explore", deprecationLogger); - // TODO: remove deprecated endpoint in 8.0.0 - controller.registerWithDeprecatedHandler( - GET, "/{index}/{type}/_graph/explore", this, - GET, "/{index}/{type}/_xpack/graph/_explore", deprecationLogger); - // TODO: remove deprecated endpoint in 8.0.0 - controller.registerWithDeprecatedHandler( - POST, "/{index}/{type}/_graph/explore", this, - POST, "/{index}/{type}/_xpack/graph/_explore", deprecationLogger); + POST, "/{index}/_graph/explore", this, + POST, "/{index}/_xpack/graph/_explore", deprecationLogger); } @Override @@ -111,10 +101,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC parseHop(parser, currentHop, graphRequest); } - if (request.hasParam("type")) { - deprecationLogger.deprecatedAndMaybeLog("graph_with_types", TYPES_DEPRECATION_MESSAGE); - graphRequest.types(Strings.splitStringByCommaToArray(request.param("type"))); - } return channel -> client.execute(INSTANCE, graphRequest, new RestToXContentListener<>(channel)); } diff --git a/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java b/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java deleted file mode 100644 index fb91e6fc5ee8a..0000000000000 --- a/x-pack/plugin/graph/src/test/java/org/elasticsearch/xpack/graph/rest/action/RestGraphActionTests.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -package org.elasticsearch.xpack.graph.rest.action; - -import org.elasticsearch.common.bytes.BytesArray; -import org.elasticsearch.common.xcontent.XContentType; -import org.elasticsearch.rest.RestRequest; -import org.elasticsearch.test.rest.FakeRestRequest; -import org.elasticsearch.test.rest.RestActionTestCase; -import org.junit.Before; - -public class RestGraphActionTests extends RestActionTestCase { - - @Before - public void setUpAction() { - new RestGraphAction(controller()); - } - - public void testTypeInPath() { - RestRequest request = new FakeRestRequest.Builder(xContentRegistry()) - .withMethod(RestRequest.Method.GET) - .withPath("/some_index/some_type/_graph/explore") - .withContent(new BytesArray("{}"), XContentType.JSON) - .build(); - - dispatchRequest(request); - assertWarnings(RestGraphAction.TYPES_DEPRECATION_MESSAGE); - } - -} diff --git a/x-pack/plugin/src/test/resources/rest-api-spec/api/graph.explore.json b/x-pack/plugin/src/test/resources/rest-api-spec/api/graph.explore.json index aa8177bb8621d..253ab219d5280 100644 --- a/x-pack/plugin/src/test/resources/rest-api-spec/api/graph.explore.json +++ b/x-pack/plugin/src/test/resources/rest-api-spec/api/graph.explore.json @@ -7,39 +7,17 @@ "url":{ "paths":[ { - "path":"/{index}/_graph/explore", - "methods":[ + "path": "/{index}/_graph/explore", + "methods": [ "GET", "POST" ], - "parts":{ - "index":{ - "type":"list", - "description":"A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" + "parts": { + "index": { + "type": "list", + "description": "A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" } } - }, - { - "path":"/{index}/{type}/_graph/explore", - "methods":[ - "GET", - "POST" - ], - "parts":{ - "index":{ - "type":"list", - "description":"A comma-separated list of index names to search; use `_all` or empty string to perform the operation on all indices" - }, - "type":{ - "type":"list", - "description":"A comma-separated list of document types to search; leave empty to perform the operation on all types", - "deprecated":true - } - }, - "deprecated":{ - "version":"7.0.0", - "description":"Specifying types in urls has been deprecated" - } } ] },