Skip to content

Commit

Permalink
REST high-level client: add support for update_all_types option to pu…
Browse files Browse the repository at this point in the history
…t mapping API

Relates to #27869
  • Loading branch information
javanna committed Jan 23, 2018
1 parent a6f2869 commit 9d7ab44
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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("/", "/", "");
Expand Down Expand Up @@ -1128,6 +1122,16 @@ private static void setRandomWaitForActiveShards(Consumer<ActiveShardCount> sett
}
}

private static void setRandomUpdateAllTypes(Consumer<Boolean> setter, Map<String, String> expectedParams) {
if (randomBoolean()) {
boolean updateAllTypes = randomBoolean();
setter.accept(updateAllTypes);
if (updateAllTypes) {
expectedParams.put("update_all_types", Boolean.TRUE.toString());
}
}
}

private static void setRandomRefreshPolicy(Consumer<WriteRequest.RefreshPolicy> setter, Map<String, String> expectedParams) {
if (randomBoolean()) {
WriteRequest.RefreshPolicy refreshPolicy = randomFrom(WriteRequest.RefreshPolicy.values());
Expand Down

0 comments on commit 9d7ab44

Please sign in to comment.