From 25a19b80785b6b9fa94a3a0a649dc2974511537b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20B=C3=BCscher?= Date: Wed, 27 May 2020 11:58:38 +0200 Subject: [PATCH] Honor IndicesOptions in HLRC putMapping request (#57118) Currently, the IndicesOptions set on a High Level rest client PutMappingRequest are not correctly converted to request parameters. This change adds the missing conversion and tests. Closes #57045 --- .../java/org/elasticsearch/client/IndicesRequestConverters.java | 1 + .../org/elasticsearch/client/IndicesRequestConvertersTests.java | 2 ++ 2 files changed, 3 insertions(+) diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java index 7ee92a4a89e9c..85fce6e534659 100644 --- a/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java +++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java @@ -137,6 +137,7 @@ static Request putMapping(PutMappingRequest putMappingRequest) throws IOExceptio RequestConverters.Params parameters = new RequestConverters.Params(); parameters.withTimeout(putMappingRequest.timeout()); parameters.withMasterTimeout(putMappingRequest.masterNodeTimeout()); + parameters.withIndicesOptions(putMappingRequest.indicesOptions()); request.addParameters(parameters.asMap()); request.setEntity(RequestConverters.createEntity(putMappingRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE)); return request; diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java index f168921f0f8a5..fc9ffca02ce3b 100644 --- a/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java +++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java @@ -166,6 +166,8 @@ public void testPutMapping() throws IOException { Map expectedParams = new HashMap<>(); RequestConvertersTests.setRandomTimeout(putMappingRequest, AcknowledgedRequest.DEFAULT_ACK_TIMEOUT, expectedParams); RequestConvertersTests.setRandomMasterTimeout(putMappingRequest, expectedParams); + RequestConvertersTests.setRandomIndicesOptions(putMappingRequest::indicesOptions, + putMappingRequest::indicesOptions, expectedParams); Request request = IndicesRequestConverters.putMapping(putMappingRequest);