浏览代码

Deprecate state field in `/_cluster/reroute` response (#90399)

Ievgen Degtiarenko 3 年之前
父节点
当前提交
4d6d979e0e

+ 13 - 0
docs/changelog/90399.yaml

@@ -0,0 +1,13 @@
+pr: 90399
+summary: Deprecate state field in /_cluster/reroute response
+area: Allocation
+type: deprecation
+issues: []
+deprecation:
+  title: state field is deprecated in /_cluster/reroute response
+  area: REST API
+  details: |-
+    `state` field is deprecated in `/_cluster/reroute` response. Cluster state does not provide meaningful information
+    about the result of reroute/commands execution. There are no guarantees that this exact state would be applied.
+  impact: |-
+    Reroute API users should not rely on `state` field and instead use `explain` to request result of commands execution.

+ 7 - 3
docs/reference/cluster/reroute.asciidoc

@@ -10,7 +10,7 @@ Changes the allocation of shards in a cluster.
 [[cluster-reroute-api-request]]
 ==== {api-request-title}
 
-`POST /_cluster/reroute`
+`POST /_cluster/reroute?metric=none`
 
 [[cluster-reroute-api-prereqs]]
 ==== {api-prereq-title}
@@ -73,7 +73,8 @@ query parameter, which will attempt a single retry round for these shards.
 
 `metric`::
     (Optional, string) Limits the information returned to the specified metrics.
-    Defaults to all but metadata The following options are available:
+    All options except `none` are deprecated and should be avoided for this parameter.
+    Defaults to all but metadata. The following options are available:
 
 +
 .Options for `metric`
@@ -96,6 +97,9 @@ query parameter, which will attempt a single retry round for these shards.
 `nodes`::
     Shows the `nodes` part of the response.
 
+`none`::
+    Excludes the entire `state` field from the response.
+
 `routing_table`::
     Shows the `routing_table` part of the response.
 
@@ -189,7 +193,7 @@ This is a short example of a simple reroute API call:
 
 [source,console]
 --------------------------------------------------
-POST /_cluster/reroute
+POST /_cluster/reroute?metric=none
 {
   "commands": [
     {

+ 1 - 1
docs/reference/commands/shard-tool.asciidoc

@@ -91,7 +91,7 @@ Changing allocation id V8QXk-QXSZinZMT-NvEq4w to tjm9Ve6uTBewVFAlfUMWjA
 
 You should run the following command to allocate this shard:
 
-POST /_cluster/reroute
+POST /_cluster/reroute?metric=none
 {
   "commands" : [
     {

+ 2 - 2
docs/reference/how-to/fix-common-cluster-issues.asciidoc

@@ -488,7 +488,7 @@ asynchronously in the background.
 
 [source,console]
 ----
-POST _cluster/reroute
+POST _cluster/reroute?metric=none
 ----
 
 **Fix allocation settings**
@@ -615,7 +615,7 @@ unassigned primary shard to another data node in the same tier. Set
 
 [source,console]
 ----
-POST _cluster/reroute
+POST _cluster/reroute?metric=none
 {
   "commands": [
     {

+ 3 - 3
docs/reference/troubleshooting/common-issues/red-yellow-cluster-status.asciidoc

@@ -91,7 +91,7 @@ asynchronously in the background.
 
 [source,console]
 ----
-POST _cluster/reroute
+POST _cluster/reroute?metric=none
 ----
 
 **Fix allocation settings**
@@ -218,7 +218,7 @@ unassigned primary shard to another data node in the same tier. Set
 
 [source,console]
 ----
-POST _cluster/reroute
+POST _cluster/reroute?metric=none
 {
   "commands": [
     {
@@ -237,4 +237,4 @@ POST _cluster/reroute
 
 If you backed up the missing index data to a snapshot, use the
 <<restore-snapshot-api,restore snapshot API>> to restore the individual index.
-Alternatively, you can index the missing data from the original data source.
+Alternatively, you can index the missing data from the original data source.

+ 1 - 0
rest-api-spec/src/main/resources/rest-api-spec/api/cluster.reroute.json

@@ -40,6 +40,7 @@
           "blocks",
           "metadata",
           "nodes",
+          "none",
           "routing_table",
           "master_node",
           "version"

+ 2 - 1
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.reroute/10_basic.yml

@@ -1,4 +1,5 @@
 ---
 "Basic sanity check":
   - do:
-      cluster.reroute: {}
+      cluster.reroute:
+        metric: none

+ 2 - 0
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.reroute/11_explain.yml

@@ -18,6 +18,7 @@ setup:
       cluster.reroute:
         explain: true
         dry_run: true
+        metric: none
         body:
           commands: []
 
@@ -38,6 +39,7 @@ setup:
       cluster.reroute:
         explain: true
         dry_run: true
+        metric: none
         body:
           commands:
             - cancel:

+ 21 - 0
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.reroute/20_deprecated_response_filtering.yml

@@ -0,0 +1,21 @@
+---
+"Do not return metadata by default and produce deprecation warning":
+  - skip:
+      features: [ "allowed_warnings" ]
+  - do:
+      cluster.reroute: {}
+      allowed_warnings:
+        - "The [state] field in the response to the reroute API is deprecated and will be removed in a future version. Specify ?metric=none to adopt the future behaviour."
+  - is_false: state.metadata
+---
+"If requested return metadata and produce deprecation warning":
+  - skip:
+      features: [ "allowed_warnings" ]
+  - do:
+      cluster.reroute:
+        metric: metadata
+      allowed_warnings:
+        - "The [state] field in the response to the reroute API is deprecated and will be removed in a future version. Specify ?metric=none to adopt the future behaviour."
+  - is_true: state.metadata
+  - is_false: state.nodes
+

+ 0 - 14
rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/cluster.reroute/20_response_filtering.yml

@@ -1,14 +0,0 @@
----
-"Do not return metadata by default":
-  - do:
-      cluster.reroute: {}
-  - is_false: state.metadata
----
-"return metadata if requested":
-  - do:
-      cluster.reroute:
-        metric: metadata
-
-  - is_true: state.metadata
-  - is_false: state.nodes
-

+ 22 - 5
server/src/main/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponse.java

@@ -13,17 +13,28 @@ import org.elasticsearch.cluster.ClusterState;
 import org.elasticsearch.cluster.routing.allocation.RoutingExplanations;
 import org.elasticsearch.common.io.stream.StreamInput;
 import org.elasticsearch.common.io.stream.StreamOutput;
-import org.elasticsearch.xcontent.ToXContent;
+import org.elasticsearch.common.logging.DeprecationCategory;
+import org.elasticsearch.common.logging.DeprecationLogger;
+import org.elasticsearch.core.RestApiVersion;
+import org.elasticsearch.rest.action.search.RestSearchAction;
 import org.elasticsearch.xcontent.ToXContentObject;
 import org.elasticsearch.xcontent.XContentBuilder;
 
 import java.io.IOException;
+import java.util.Objects;
 
 /**
  * Response returned after a cluster reroute request
  */
 public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXContentObject {
 
+    private static final DeprecationLogger deprecationLogger = DeprecationLogger.getLogger(RestSearchAction.class);
+    public static final String STATE_FIELD_DEPRECATION_MESSAGE = "The [state] field in the response to the reroute API is deprecated "
+        + "and will be removed in a future version. Specify ?metric=none to adopt the future behaviour.";
+
+    /**
+     * To be removed when REST compatibility with {@link org.elasticsearch.Version#V_8_6_0} / {@link RestApiVersion#V_8} no longer needed
+     */
     private final ClusterState state;
     private final RoutingExplanations explanations;
 
@@ -59,11 +70,17 @@ public class ClusterRerouteResponse extends AcknowledgedResponse implements ToXC
 
     @Override
     protected void addCustomFields(XContentBuilder builder, Params params) throws IOException {
-        builder.startObject("state");
-        state.toXContent(builder, params);
-        builder.endObject();
+        if (Objects.equals(params.param("metric"), "none") == false) {
+            if (builder.getRestApiVersion() != RestApiVersion.V_7) {
+                deprecationLogger.critical(DeprecationCategory.API, "reroute_cluster_state", STATE_FIELD_DEPRECATION_MESSAGE);
+            }
+            builder.startObject("state");
+            state.toXContent(builder, params);
+            builder.endObject();
+        }
+
         if (params.paramAsBoolean("explain", false)) {
-            explanations.toXContent(builder, ToXContent.EMPTY_PARAMS);
+            explanations.toXContent(builder, params);
         }
     }
 }

+ 9 - 2
server/src/main/java/org/elasticsearch/cluster/routing/allocation/AllocationService.java

@@ -710,7 +710,14 @@ public class AllocationService {
      * {@link org.elasticsearch.cluster.routing.allocation.command.AllocationCommand}
      */
     public record CommandsResult(
-        RoutingExplanations explanations, // Explanation for the reroute actions
-        ClusterState clusterState         // Resulting cluster state
+        /**
+         * Explanation for the reroute actions
+         */
+        RoutingExplanations explanations,
+        /**
+         * Resulting cluster state, to be removed when REST compatibility with
+         * {@link org.elasticsearch.Version#V_8_6_0} / {@link RestApiVersion#V_8} no longer needed
+         */
+        ClusterState clusterState
     ) {}
 }

+ 241 - 204
server/src/test/java/org/elasticsearch/action/admin/cluster/reroute/ClusterRerouteResponseTests.java

@@ -26,229 +26,266 @@ import org.elasticsearch.common.xcontent.XContentHelper;
 import org.elasticsearch.index.IndexSettings;
 import org.elasticsearch.test.ESTestCase;
 import org.elasticsearch.xcontent.ToXContent;
-import org.elasticsearch.xcontent.XContentBuilder;
 import org.elasticsearch.xcontent.json.JsonXContent;
 
 import java.io.IOException;
-import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
+import static org.elasticsearch.common.util.CollectionUtils.appendToCopy;
+import static org.hamcrest.Matchers.equalTo;
+
 public class ClusterRerouteResponseTests extends ESTestCase {
 
+    @Override
+    protected List<String> filteredWarnings() {
+        return appendToCopy(super.filteredWarnings(), ClusterRerouteResponse.STATE_FIELD_DEPRECATION_MESSAGE);
+    }
+
     public void testToXContent() throws IOException {
-        DiscoveryNode node0 = new DiscoveryNode("node0", new TransportAddress(TransportAddress.META_ADDRESS, 9000), Version.CURRENT);
-        DiscoveryNodes nodes = new DiscoveryNodes.Builder().add(node0).masterNodeId(node0.getId()).build();
-        IndexMetadata indexMetadata = IndexMetadata.builder("index")
-            .settings(
-                Settings.builder()
-                    .put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), true)
-                    .put(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.getKey(), 10)
-                    .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
-                    .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
-                    .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
-                    .build()
-            )
-            .build();
-        Metadata metadata = Metadata.builder().indices(Map.of("index", indexMetadata)).build();
-        ClusterState clusterState = ClusterState.builder(new ClusterName("test")).nodes(nodes).metadata(metadata).build();
-
-        RoutingExplanations routingExplanations = new RoutingExplanations();
-        routingExplanations.add(new RerouteExplanation(new AllocateReplicaAllocationCommand("index", 0, "node0"), Decision.YES));
-        ClusterRerouteResponse clusterRerouteResponse = new ClusterRerouteResponse(true, clusterState, routingExplanations);
-        {
-            XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint();
-            clusterRerouteResponse.toXContent(builder, ToXContent.EMPTY_PARAMS);
-            assertEquals(
-                XContentHelper.stripWhitespace("""
-                    {
-                      "acknowledged": true,
-                      "state": {
-                        "cluster_uuid": "_na_",
-                        "version": 0,
-                        "state_uuid": "%s",
-                        "master_node": "node0",
-                        "blocks": {},
-                        "nodes": {
-                          "node0": {
-                            "name": "",
-                            "ephemeral_id": "%s",
-                            "transport_address": "0.0.0.0:9000",
-                            "external_id": "",
-                            "attributes": {},
-                            "roles": [
-                              "data",
-                              "data_cold",
-                              "data_content",
-                              "data_frozen",
-                              "data_hot",
-                              "data_warm",
-                              "ingest",
-                              "master",
-                              "ml",
-                              "remote_cluster_client",
-                              "transform",
-                              "voting_only"
-                            ]
-                          }
-                        },
-                        "metadata": {
-                          "cluster_uuid": "_na_",
-                          "cluster_uuid_committed": false,
-                          "cluster_coordination": {
-                            "term": 0,
-                            "last_committed_config": [],
-                            "last_accepted_config": [],
-                            "voting_config_exclusions": []
-                          },
-                          "templates": {},
-                          "indices": {
-                            "index": {
-                              "version": 1,
-                              "mapping_version": 1,
-                              "settings_version": 1,
-                              "aliases_version": 1,
-                              "routing_num_shards": 1,
-                              "state": "open",
-                              "settings": {
-                                "index": {
-                                  "shard": {
-                                    "check_on_startup": "true"
-                                  },
-                                  "number_of_shards": "1",
-                                  "number_of_replicas": "0",
-                                  "version": {
-                                    "created": "%s"
-                                  },
-                                  "max_script_fields": "10"
-                                }
-                              },
-                              "mappings": {},
-                              "aliases": [],
-                              "primary_terms": {
-                                "0": 0
-                              },
-                              "in_sync_allocations": {
-                                "0": []
-                              },
-                              "rollover_info": {},
-                              "system": false,
-                              "timestamp_range": {
-                                "shards": []
-                              }
-                            }
-                          },
-                          "index-graveyard": {
-                            "tombstones": []
-                          },
-                          "reserved_state":{}
-                        },
-                        "routing_table": {
-                          "indices": {}
-                        },
-                        "routing_nodes": {
-                          "unassigned": [],
-                          "nodes": {
-                            "node0": []
-                          }
-                        }
-                      }
-                    }""".formatted(clusterState.stateUUID(), node0.getEphemeralId(), Version.CURRENT.id)),
-                XContentHelper.stripWhitespace(Strings.toString(builder))
-            );
-        }
-        {
-            XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint();
-            Map<String, String> params = new HashMap<>();
-            params.put("explain", "true");
-            params.put("metric", "version,master_node");
-            clusterRerouteResponse.toXContent(builder, new ToXContent.MapParams(params));
-            assertEquals(XContentHelper.stripWhitespace("""
+        var clusterState = createClusterState();
+        var clusterRerouteResponse = createClusterRerouteResponse(clusterState);
+
+        var result = toXContent(clusterRerouteResponse, new ToXContent.MapParams(Map.of("metric", "none")));
+
+        assertThat(result, equalTo(XContentHelper.stripWhitespace("""
+            {
+              "acknowledged": true
+            }""")));
+    }
+
+    public void testToXContentWithExplain() throws IOException {
+        var clusterState = createClusterState();
+        var clusterRerouteResponse = createClusterRerouteResponse(clusterState);
+
+        var result = toXContent(clusterRerouteResponse, new ToXContent.MapParams(Map.of("explain", "true", "metric", "none")));
+
+        assertThat(result, equalTo(XContentHelper.stripWhitespace("""
+            {
+              "acknowledged": true,
+              "explanations": [
                 {
-                  "acknowledged": true,
-                  "state": {
-                    "cluster_uuid": "_na_",
-                    "version": 0,
-                    "state_uuid": "%s",
-                    "master_node": "node0"
+                  "command": "allocate_replica",
+                  "parameters": {
+                    "index": "index",
+                    "shard": 0,
+                    "node": "node0"
                   },
-                  "explanations": [
+                  "decisions": [
                     {
-                      "command": "allocate_replica",
-                      "parameters": {
-                        "index": "index",
-                        "shard": 0,
-                        "node": "node0"
-                      },
-                      "decisions": [
-                        {
-                          "decider": null,
-                          "decision": "YES",
-                          "explanation": "none"
-                        }
-                      ]
+                      "decider": null,
+                      "decision": "YES",
+                      "explanation": "none"
                     }
                   ]
-                }""".formatted(clusterState.stateUUID())), XContentHelper.stripWhitespace(Strings.toString(builder)));
-        }
-        {
-            XContentBuilder builder = JsonXContent.contentBuilder().prettyPrint();
-            Map<String, String> params = new HashMap<>();
-            params.put("metric", "metadata");
-            params.put("settings_filter", "index.number*,index.version.created");
-            clusterRerouteResponse.toXContent(builder, new ToXContent.MapParams(params));
-            assertEquals(XContentHelper.stripWhitespace("""
-                {
-                  "acknowledged" : true,
-                  "state" : {
-                    "cluster_uuid" : "_na_",
-                    "metadata" : {
-                      "cluster_uuid" : "_na_",
-                      "cluster_uuid_committed" : false,
-                      "cluster_coordination" : {
-                        "term" : 0,
-                        "last_committed_config" : [ ],
-                        "last_accepted_config" : [ ],
-                        "voting_config_exclusions" : [ ]
-                      },
-                      "templates" : { },
-                      "indices" : {
-                        "index" : {
-                          "version" : 1,
-                          "mapping_version" : 1,
-                          "settings_version" : 1,
-                          "aliases_version" : 1,
-                          "routing_num_shards" : 1,
-                          "state" : "open",
-                          "settings" : {
-                            "index" : {
-                              "max_script_fields" : "10",
-                              "shard" : {
-                                "check_on_startup" : "true"
-                              }
-                            }
-                          },
-                          "mappings" : { },
-                          "aliases" : [ ],
-                          "primary_terms" : {
-                            "0" : 0
+                }
+              ]
+            }""".formatted(clusterState.stateUUID()))));
+
+    }
+
+    public void testToXContentWithDeprecatedClusterState() throws IOException {
+        var clusterState = createClusterState();
+        var clusterRerouteResponse = createClusterRerouteResponse(clusterState);
+
+        var result = toXContent(clusterRerouteResponse, ToXContent.EMPTY_PARAMS);
+
+        assertThat(result, equalTo(XContentHelper.stripWhitespace("""
+            {
+              "acknowledged": true,
+              "state": {
+                "cluster_uuid": "_na_",
+                "version": 0,
+                "state_uuid": "%s",
+                "master_node": "node0",
+                "blocks": {},
+                "nodes": {
+                  "node0": {
+                    "name": "",
+                    "ephemeral_id": "%s",
+                    "transport_address": "0.0.0.0:9000",
+                    "external_id": "",
+                    "attributes": {},
+                    "roles": [
+                      "data",
+                      "data_cold",
+                      "data_content",
+                      "data_frozen",
+                      "data_hot",
+                      "data_warm",
+                      "ingest",
+                      "master",
+                      "ml",
+                      "remote_cluster_client",
+                      "transform",
+                      "voting_only"
+                    ]
+                  }
+                },
+                "metadata": {
+                  "cluster_uuid": "_na_",
+                  "cluster_uuid_committed": false,
+                  "cluster_coordination": {
+                    "term": 0,
+                    "last_committed_config": [],
+                    "last_accepted_config": [],
+                    "voting_config_exclusions": []
+                  },
+                  "templates": {},
+                  "indices": {
+                    "index": {
+                      "version": 1,
+                      "mapping_version": 1,
+                      "settings_version": 1,
+                      "aliases_version": 1,
+                      "routing_num_shards": 1,
+                      "state": "open",
+                      "settings": {
+                        "index": {
+                          "shard": {
+                            "check_on_startup": "true"
                           },
-                          "in_sync_allocations" : {
-                            "0" : [ ]
+                          "number_of_shards": "1",
+                          "number_of_replicas": "0",
+                          "version": {
+                            "created": "%s"
                           },
-                          "rollover_info" : { },
-                          "system" : false,
-                          "timestamp_range" : {
-                            "shards" : [ ]
-                          }
+                          "max_script_fields": "10"
                         }
                       },
-                      "index-graveyard" : {
-                        "tombstones" : [ ]
+                      "mappings": {},
+                      "aliases": [],
+                      "primary_terms": {
+                        "0": 0
+                      },
+                      "in_sync_allocations": {
+                        "0": []
                       },
-                      "reserved_state":{}
+                      "rollover_info": {},
+                      "system": false,
+                      "timestamp_range": {
+                        "shards": []
+                      }
                     }
+                  },
+                  "index-graveyard": {
+                    "tombstones": []
+                  },
+                  "reserved_state":{}
+                },
+                "routing_table": {
+                  "indices": {}
+                },
+                "routing_nodes": {
+                  "unassigned": [],
+                  "nodes": {
+                    "node0": []
                   }
-                }"""), XContentHelper.stripWhitespace(Strings.toString(builder)));
-        }
+                }
+              }
+            }""".formatted(clusterState.stateUUID(), clusterState.getNodes().get("node0").getEphemeralId(), Version.CURRENT.id))));
+    }
+
+    public void testToXContentWithDeprecatedClusterStateAndMetadata() throws IOException {
+        var clusterState = createClusterState();
+        var clusterRerouteResponse = createClusterRerouteResponse(clusterState);
+
+        var result = toXContent(
+            clusterRerouteResponse,
+            new ToXContent.MapParams(Map.of("metric", "metadata", "settings_filter", "index.number*,index.version.created"))
+        );
+
+        assertThat(result, equalTo(XContentHelper.stripWhitespace("""
+            {
+              "acknowledged" : true,
+              "state" : {
+                "cluster_uuid" : "_na_",
+                "metadata" : {
+                  "cluster_uuid" : "_na_",
+                  "cluster_uuid_committed" : false,
+                  "cluster_coordination" : {
+                    "term" : 0,
+                    "last_committed_config" : [ ],
+                    "last_accepted_config" : [ ],
+                    "voting_config_exclusions" : [ ]
+                  },
+                  "templates" : { },
+                  "indices" : {
+                    "index" : {
+                      "version" : 1,
+                      "mapping_version" : 1,
+                      "settings_version" : 1,
+                      "aliases_version" : 1,
+                      "routing_num_shards" : 1,
+                      "state" : "open",
+                      "settings" : {
+                        "index" : {
+                          "max_script_fields" : "10",
+                          "shard" : {
+                            "check_on_startup" : "true"
+                          }
+                        }
+                      },
+                      "mappings" : { },
+                      "aliases" : [ ],
+                      "primary_terms" : {
+                        "0" : 0
+                      },
+                      "in_sync_allocations" : {
+                        "0" : [ ]
+                      },
+                      "rollover_info" : { },
+                      "system" : false,
+                      "timestamp_range" : {
+                        "shards" : [ ]
+                      }
+                    }
+                  },
+                  "index-graveyard" : {
+                    "tombstones" : [ ]
+                  },
+                  "reserved_state":{}
+                }
+              }
+            }""")));
+    }
+
+    private static String toXContent(ClusterRerouteResponse clusterRerouteResponse, ToXContent.Params params) throws IOException {
+        var builder = JsonXContent.contentBuilder().prettyPrint();
+        clusterRerouteResponse.toXContent(builder, params);
+        return XContentHelper.stripWhitespace(Strings.toString(builder));
+    }
+
+    private static ClusterRerouteResponse createClusterRerouteResponse(ClusterState clusterState) {
+        return new ClusterRerouteResponse(
+            true,
+            clusterState,
+            new RoutingExplanations().add(new RerouteExplanation(new AllocateReplicaAllocationCommand("index", 0, "node0"), Decision.YES))
+        );
+    }
+
+    private static ClusterState createClusterState() {
+        var node0 = new DiscoveryNode("node0", new TransportAddress(TransportAddress.META_ADDRESS, 9000), Version.CURRENT);
+        return ClusterState.builder(new ClusterName("test"))
+            .nodes(new DiscoveryNodes.Builder().add(node0).masterNodeId(node0.getId()).build())
+            .metadata(
+                Metadata.builder()
+                    .put(
+                        IndexMetadata.builder("index")
+                            .settings(
+                                Settings.builder()
+                                    .put(IndexSettings.INDEX_CHECK_ON_STARTUP.getKey(), true)
+                                    .put(IndexSettings.MAX_SCRIPT_FIELDS_SETTING.getKey(), 10)
+                                    .put(IndexMetadata.SETTING_NUMBER_OF_SHARDS, 1)
+                                    .put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, 0)
+                                    .put(IndexMetadata.SETTING_VERSION_CREATED, Version.CURRENT)
+                                    .build()
+                            )
+                            .build(),
+                        false
+                    )
+                    .build()
+            )
+            .build();
     }
 }