diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/Request.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/Request.java index d84cd60409ba7..3eaadaefdb0f1 100755 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/Request.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/Request.java @@ -191,6 +191,7 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio Params parameters = Params.builder(); parameters.withTimeout(putMappingRequest.timeout()); parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout()); + parameters.withUpdateAllTypes(putMappingRequest.updateAllTypes()); HttpEntity entity = createEntity(putMappingRequest, REQUEST_BODY_CONTENT_TYPE); return new Request(HttpPut.METHOD_NAME, endpoint, parameters.getParams(), entity); diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java index 76087ad914993..6dae936d8d163 100755 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/RequestTests.java @@ -310,14 +310,7 @@ public void testCreateIndex() throws IOException { setRandomTimeout(createIndexRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); setRandomMasterTimeout(createIndexRequest, expectedParams); setRandomWaitForActiveShards(createIndexRequest::waitForActiveShards, ActiveShardCount.DEFAULT, expectedParams); - - if (randomBoolean()) { - boolean updateAllTypes = randomBoolean(); - createIndexRequest.updateAllTypes(updateAllTypes); - if (updateAllTypes) { - expectedParams.put("update_all_types", Boolean.TRUE.toString()); - } - } + setRandomUpdateAllTypes(createIndexRequest::updateAllTypes, expectedParams); Request request = Request.createIndex(createIndexRequest); assertEquals("/" + indexName, request.getEndpoint()); @@ -343,6 +336,7 @@ public void testPutMapping() throws IOException { setRandomTimeout(putMappingRequest::timeout, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); setRandomMasterTimeout(putMappingRequest, expectedParams); + setRandomUpdateAllTypes(putMappingRequest::updateAllTypes, expectedParams); Request request = Request.putMapping(putMappingRequest); StringJoiner endpoint = new StringJoiner("/", "/", ""); @@ -1128,6 +1122,16 @@ private static void setRandomWaitForActiveShards(Consumer sett } } + private static void setRandomUpdateAllTypes(Consumer setter, Map expectedParams) { + if (randomBoolean()) { + boolean updateAllTypes = randomBoolean(); + setter.accept(updateAllTypes); + if (updateAllTypes) { + expectedParams.put("update_all_types", Boolean.TRUE.toString()); + } + } + } + private static void setRandomRefreshPolicy(Consumer setter, Map expectedParams) { if (randomBoolean()) { WriteRequest.RefreshPolicy refreshPolicy = randomFrom(WriteRequest.RefreshPolicy.values());