From 6763bf6dbf5795d5c80157d8691314d91f40b08f Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Tue, 21 Jul 2020 10:19:54 -0400 Subject: [PATCH 1/3] [DOCS] Fix shrink index API prereqs Adds a recommendation for removing replica shards to the prereqs of the shrink index API docs. Also clarifies some of the existing prereqs. --- docs/reference/indices/shrink-index.asciidoc | 26 +++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/docs/reference/indices/shrink-index.asciidoc b/docs/reference/indices/shrink-index.asciidoc index f6da7c6b64bbc..8e301330dc6c0 100644 --- a/docs/reference/indices/shrink-index.asciidoc +++ b/docs/reference/indices/shrink-index.asciidoc @@ -28,28 +28,36 @@ POST /twitter/_shrink/shrunk-twitter-index Before you can shrink an index: * The index must be read-only. -* A copy of every shard in the index must reside on the same node. -* The <> status must be green. +* All primary and replica shards for the index must be allocated to the same node. +* The index must have a `green` <>. -These three conditions can be achieved with the following request: +To make shard allocation easier, we recommend you first remove the index's +replica shards. You can later re-add replica shards as part of the shrink +operation. + +You can use the following <> +request to remove an index's replica shards, reallocate the index's remaining +shards to the same node, and make the index read-only. [source,console] -------------------------------------------------- PUT /my_source_index/_settings { "settings": { - "index.routing.allocation.require._name": "shrink_node_name", <1> - "index.blocks.write": true <2> + "index.number_of_replicas": 0, <1> + "index.routing.allocation.require._name": "shrink_node_name", <2> + "index.blocks.write": true <3> } } -------------------------------------------------- // TEST[s/^/PUT my_source_index\n{"settings":{"index.number_of_shards":2}}\n/] -<1> Forces the relocation of a copy of each shard to the node with name - `shrink_node_name`. See <> for more options. +<1> Removes replica shards for the index. +<2> Relocates the index's shards to the `shrink_node_name` node. + See <>. +<3> Prevents write operations to this index. Metadata changes, such as deleting + the index, are still allowed. -<2> Prevents write operations to this index while still allowing metadata - changes like deleting the index. It can take a while to relocate the source index. Progress can be tracked with the <>, or the < Date: Tue, 21 Jul 2020 13:17:53 -0400 Subject: [PATCH 2/3] reword --- docs/reference/indices/shrink-index.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/indices/shrink-index.asciidoc b/docs/reference/indices/shrink-index.asciidoc index 8e301330dc6c0..c1b6ae8b0e272 100644 --- a/docs/reference/indices/shrink-index.asciidoc +++ b/docs/reference/indices/shrink-index.asciidoc @@ -28,7 +28,7 @@ POST /twitter/_shrink/shrunk-twitter-index Before you can shrink an index: * The index must be read-only. -* All primary and replica shards for the index must be allocated to the same node. +* All primary and replica shards for the index must reside on the same node. * The index must have a `green` <>. To make shard allocation easier, we recommend you first remove the index's @@ -36,7 +36,7 @@ replica shards. You can later re-add replica shards as part of the shrink operation. You can use the following <> -request to remove an index's replica shards, reallocate the index's remaining +request to remove an index's replica shards, relocates the index's remaining shards to the same node, and make the index read-only. [source,console] From 1cc94d114e5eff7667849ee0cf2dfcd500591825 Mon Sep 17 00:00:00 2001 From: James Rodewig Date: Wed, 22 Jul 2020 09:50:54 -0400 Subject: [PATCH 3/3] address feedback --- docs/reference/indices/shrink-index.asciidoc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/reference/indices/shrink-index.asciidoc b/docs/reference/indices/shrink-index.asciidoc index c1b6ae8b0e272..4498b12abb2cd 100644 --- a/docs/reference/indices/shrink-index.asciidoc +++ b/docs/reference/indices/shrink-index.asciidoc @@ -28,10 +28,10 @@ POST /twitter/_shrink/shrunk-twitter-index Before you can shrink an index: * The index must be read-only. -* All primary and replica shards for the index must reside on the same node. +* All primary shards for the index must reside on the same node. * The index must have a `green` <>. -To make shard allocation easier, we recommend you first remove the index's +To make shard allocation easier, we recommend you also remove the index's replica shards. You can later re-add replica shards as part of the shrink operation.