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 51b9cbc57b91a..8d1b7dfe02046 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
@@ -342,6 +342,7 @@ private static Request resize(ResizeRequest resizeRequest) throws IOException {
params.withTimeout(resizeRequest.timeout());
params.withMasterTimeout(resizeRequest.masterNodeTimeout());
params.withWaitForActiveShards(resizeRequest.getTargetIndexRequest().waitForActiveShards(), ActiveShardCount.DEFAULT);
+ params.withCopySettings(resizeRequest.getCopySettings());
request.setEntity(RequestConverters.createEntity(resizeRequest, RequestConverters.REQUEST_BODY_CONTENT_TYPE));
return request;
diff --git a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
index 4e3628a181035..293fa85ddbd5f 100644
--- a/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
+++ b/client/rest-high-level/src/main/java/org/elasticsearch/client/RequestConverters.java
@@ -909,6 +909,17 @@ Params withWaitForActiveShards(ActiveShardCount activeShardCount) {
return withWaitForActiveShards(activeShardCount, ActiveShardCount.DEFAULT);
}
+ /**
+ * @deprecated copy_settings
can not be set to false. If unset, behaves as false
and won't copy settings.
+ */
+ @Deprecated
+ Params withCopySettings(Boolean setCopySettings) {
+ if (setCopySettings != null) {
+ return putParam("copy_settings", setCopySettings.toString());
+ }
+ return this;
+ }
+
Params withIndicesOptions(IndicesOptions indicesOptions) {
if (indicesOptions != null) {
withIgnoreUnavailable(indicesOptions.ignoreUnavailable());
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 9a6c123ace719..d3d8507dfafcf 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
@@ -868,6 +868,12 @@ private void resizeTest(ResizeType resizeType, CheckedFunction expectedParams = new HashMap<>();
+
+ if (randomBoolean()) {
+ resizeRequest.setCopySettings(true);
+ expectedParams.put("copy_settings", "true");
+ }
+
RequestConvertersTests.setRandomMasterTimeout(resizeRequest, expectedParams);
RequestConvertersTests.setRandomTimeout(resizeRequest::timeout, resizeRequest.timeout(), expectedParams);
diff --git a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
index 77f2e7aed133e..35d54371df2b9 100644
--- a/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
+++ b/client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/IndicesClientDocumentationIT.java
@@ -1683,9 +1683,13 @@ public void testShrinkIndex() throws Exception {
request.setWaitForActiveShards(2); // <1>
request.setWaitForActiveShards(ActiveShardCount.DEFAULT); // <2>
// end::shrink-index-request-waitForActiveShards
+ // tag::shrink-index-request-copySettings
+ request.setCopySettings(true); // <1>
+ // end::shrink-index-request-copySettings
// tag::shrink-index-request-settings
request.getTargetIndexRequest().settings(Settings.builder()
- .put("index.number_of_shards", 2)); // <1>
+ .put("index.number_of_shards", 2) // <1>
+ .putNull("index.routing.allocation.require._name")); // <2>
// end::shrink-index-request-settings
// tag::shrink-index-request-aliases
request.getTargetIndexRequest().alias(new Alias("target_alias")); // <1>
diff --git a/docs/java-rest/high-level/indices/shrink_index.asciidoc b/docs/java-rest/high-level/indices/shrink_index.asciidoc
index 3a1d61d821dac..31f2f16c6a3d7 100644
--- a/docs/java-rest/high-level/indices/shrink_index.asciidoc
+++ b/docs/java-rest/high-level/indices/shrink_index.asciidoc
@@ -47,12 +47,21 @@ returns a response, as an `int`
<2> The number of active shard copies to wait for before the shrink index API
returns a response, as an `ActiveShardCount`
+["source","java",subs="attributes,callouts,macros"]
+--------------------------------------------------
+include-tagged::{doc-tests-file}[{api}-request-copySettings]
+--------------------------------------------------
+<1> Use `true` to copy the settings from the source index to the target
+index. This cannot be `false`. If this method is not used, default behavior is
+not to copy. This parameter will be removed in 8.0.0.
+
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-settings]
--------------------------------------------------
<1> The settings to apply to the target index, which include the number of
shards to create for it
+<2> Remove the allocation requirement copied from the source index
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------