diff --git a/src/test/java/org/elasticsearch/test/rest/client/RestClient.java b/src/test/java/org/elasticsearch/test/rest/client/RestClient.java index e1e0847669e..c18ef40b886 100644 --- a/src/test/java/org/elasticsearch/test/rest/client/RestClient.java +++ b/src/test/java/org/elasticsearch/test/rest/client/RestClient.java @@ -156,7 +156,11 @@ public class RestClient implements Closeable { } private HttpRequestBuilder callApiBuilder(String apiName, Map params, String body) { - RestApi restApi = restApi(apiName); + + //create doesn't exist in the spec but is supported in the clients (index with op_type=create) + boolean indexCreateApi = "create".equals(apiName); + String api = indexCreateApi ? "index" : apiName; + RestApi restApi = restApi(api); HttpRequestBuilder httpRequestBuilder = httpRequestBuilder(); @@ -186,6 +190,10 @@ public class RestClient implements Closeable { } } + if (indexCreateApi) { + httpRequestBuilder.addParam("op_type", "create"); + } + //the http method is randomized (out of the available ones with the chosen api) return httpRequestBuilder.method(RandomizedTest.randomFrom(restApi.getSupportedMethods(pathParts.keySet()))) .path(RandomizedTest.randomFrom(restApi.getFinalPaths(pathParts))); diff --git a/src/test/java/org/elasticsearch/test/rest/spec/RestSpec.java b/src/test/java/org/elasticsearch/test/rest/spec/RestSpec.java index bbfa8103f79..6da859151e5 100644 --- a/src/test/java/org/elasticsearch/test/rest/spec/RestSpec.java +++ b/src/test/java/org/elasticsearch/test/rest/spec/RestSpec.java @@ -38,22 +38,6 @@ public class RestSpec { } void addApi(RestApi restApi) { - if ("index".equals(restApi.getName())) { - RestApi create = new RestApi("create"); - create.addPath("/{index}/{type}"); - create.addPath("/{index}/{type}/{id}/_create"); - create.setBodyRequired(); - for (String method : restApi.getMethods()) { - create.addMethod(method); - } - for (String param : restApi.getParams()) { - create.addParam(param); - } - for (String pathPart : restApi.getPathParts()) { - create.addPathPart(pathPart); - } - restApiMap.put(create.getName(), create); - } restApiMap.put(restApi.getName(), restApi); }