Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class GraphRequestConverters {
private GraphRequestConverters() {}

static Request explore(GraphExploreRequest exploreRequest) throws IOException {
String endpoint = RequestConverters.endpoint(exploreRequest.indices(), exploreRequest.types(), "_xpack/graph/_explore");
String endpoint = RequestConverters.endpoint(exploreRequest.indices(), exploreRequest.types(), "_graph/explore");
Request request = new Request(HttpGet.METHOD_NAME, endpoint);
request.setEntity(RequestConverters.createEntity(exploreRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
package org.elasticsearch.client;

import org.apache.http.client.methods.HttpGet;
import org.elasticsearch.client.graph.GraphExploreRequest;
import org.elasticsearch.client.graph.Hop;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilder;
import org.elasticsearch.index.query.TermQueryBuilder;
import org.elasticsearch.client.graph.GraphExploreRequest;
import org.elasticsearch.client.graph.Hop;
import org.elasticsearch.test.ESTestCase;

import java.util.HashMap;
Expand Down Expand Up @@ -58,7 +58,7 @@ public void testGraphExplore() throws Exception {
}
Request request = GraphRequestConverters.explore(graphExploreRequest);
assertEquals(HttpGet.METHOD_NAME, request.getMethod());
assertEquals("/index1,index2/type1,type2/_xpack/graph/_explore", request.getEndpoint());
assertEquals("/index1,index2/type1,type2/_graph/explore", request.getEndpoint());
assertEquals(expectedParams, request.getParameters());
assertThat(request.getEntity().getContentType().getValue(), is(XContentType.JSON.mediaTypeWithoutParameters()));
RequestConvertersTests.assertToXContentBody(graphExploreRequest, request.getEntity());
Expand Down
8 changes: 4 additions & 4 deletions docs/reference/graph/explore.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ For additional information about working with the explore API, see the Graph
[float]
=== Request

`POST <index>/_xpack/graph/_explore`
`POST <index>/_graph/explore`

[float]
=== Description
Expand Down Expand Up @@ -183,7 +183,7 @@ An initial search typically begins with a query to identify strongly related ter

[source,js]
--------------------------------------------------
POST clicklogs/_xpack/graph/_explore
POST clicklogs/_graph/explore
{
"query": { <1>
"match": {
Expand Down Expand Up @@ -288,7 +288,7 @@ every document could be of interest, see the

[source,js]
--------------------------------------------------
POST clicklogs/_xpack/graph/_explore
POST clicklogs/_graph/explore
{
"query": {
"match": {
Expand Down Expand Up @@ -375,7 +375,7 @@ out to find additional search terms associated with that product. The terms

[source,js]
--------------------------------------------------
POST clicklogs/_xpack/graph/_explore
POST clicklogs/_graph/explore
{
"vertices": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@
* 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.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.elasticsearch.ElasticsearchParseException;
import org.elasticsearch.action.support.IndicesOptions;
import org.elasticsearch.common.ParseField;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.XContentParser;
Expand Down Expand Up @@ -38,7 +39,8 @@
* @see GraphExploreRequest
*/
public class RestGraphAction extends XPackRestHandler {
private static final Logger logger = LogManager.getLogger(RestGraphAction.class);

private static final DeprecationLogger deprecationLogger = new DeprecationLogger(LogManager.getLogger(RestGraphAction.class));

public static final ParseField TIMEOUT_FIELD = new ParseField("timeout");
public static final ParseField SIGNIFICANCE_FIELD = new ParseField("use_significance");
Expand All @@ -61,16 +63,27 @@ public class RestGraphAction extends XPackRestHandler {

public RestGraphAction(Settings settings, RestController controller) {
super(settings);

controller.registerHandler(GET, "/{index}" + URI_BASE + "/graph/_explore", this);
controller.registerHandler(POST, "/{index}" + URI_BASE + "/graph/_explore", this);
controller.registerHandler(GET, "/{index}/{type}" + URI_BASE + "/graph/_explore", this);
controller.registerHandler(POST, "/{index}/{type}" + URI_BASE + "/graph/_explore", this);
// TODO: remove deprecated endpoint in 8.0.0
controller.registerWithDeprecatedHandler(
GET, "/{index}/_graph/explore", this,
GET, "/{index}" + URI_BASE + "/graph/_explore", deprecationLogger);
// TODO: remove deprecated endpoint in 8.0.0
controller.registerWithDeprecatedHandler(
POST, "/{index}/_graph/explore", this,
POST, "/{index}" + URI_BASE + "/graph/_explore", deprecationLogger);
// TODO: remove deprecated endpoint in 8.0.0
controller.registerWithDeprecatedHandler(
GET, "/{index}/{type}/_graph/explore", this,
GET, "/{index}/{type}" + URI_BASE + "/graph/_explore", deprecationLogger);
// TODO: remove deprecated endpoint in 8.0.0
controller.registerWithDeprecatedHandler(
POST, "/{index}/{type}/_graph/explore", this,
POST, "/{index}/{type}" + URI_BASE + "/graph/_explore", deprecationLogger);
}

@Override
public String getName() {
return "xpack_graph_action";
return "graph";
}

@Override
Expand Down Expand Up @@ -323,4 +336,5 @@ private void parseControls(XContentParser parser, GraphExploreRequest graphReque
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"documentation": "https://www.elastic.co/guide/en/elasticsearch/reference/current/graph-explore-api.html",
"methods": ["GET", "POST"],
"url": {
"path": "/{index}/_xpack/graph/_explore",
"paths": ["/{index}/_xpack/graph/_explore", "/{index}/{type}/_xpack/graph/_explore"],
"path": "/{index}/_graph/explore",
"paths": ["/{index}/_graph/explore", "/{index}/{type}/_graph/explore"],
"parts" : {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the _xpack?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@markharwood Oops, thanks! I pushed a2dc134.

"index": {
"type" : "list",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ setup:

---
"Test basic graph explore":
- skip:
version: " - 6.99.99"
reason: "graph endpoints changed in 7.0.0 to not include _xpack in the path but this is not supported in 6.x"
- do:
index:
index: test_1
Expand Down