Skip to content

Commit

Permalink
Use index block API in shrink/split/clone docs (elastic#105997)
Browse files Browse the repository at this point in the history
This uses the dedicated index block API in the docs for the shrink, split, and clone APIs, rather than putting the block in as a setting directly. The specialized API will wait for ongoing operations to finish, which is better during indexing operations.

Resolves elastic#105831
  • Loading branch information
dakrone authored Mar 6, 2024
1 parent e238527 commit 9a049a1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
10 changes: 3 additions & 7 deletions docs/reference/indices/clone-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,13 @@ POST /my-index-000001/_clone/cloned-my-index-000001

For example,
the following request prevents write operations on `my_source_index`
so it can be cloned.
so it can be cloned using the
<<add-index-block,add index block>> API.
Metadata changes like deleting the index are still allowed.

[source,console]
--------------------------------------------------
PUT /my_source_index/_settings
{
"settings": {
"index.blocks.write": true
}
}
PUT /my_source_index/_block/write
--------------------------------------------------
// TEST[s/^/PUT my_source_index\n/]

Expand Down
18 changes: 11 additions & 7 deletions docs/reference/indices/shrink-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,16 @@ replica shards. You can later re-add replica shards as part of the shrink
operation.

You can use the following <<indices-update-settings,update index settings API>>
request to remove an index's replica shards, relocates the index's remaining
shards to the same node, and make the index read-only.
request to remove an index's replica shards, and relocate the index's remaining
shards to the same node.

[source,console]
--------------------------------------------------
PUT /my_source_index/_settings
{
"settings": {
"index.number_of_replicas": 0, <1>
"index.routing.allocation.require._name": "shrink_node_name", <2>
"index.blocks.write": true <3>
"index.routing.allocation.require._name": "shrink_node_name" <2>
}
}
--------------------------------------------------
Expand All @@ -58,15 +57,20 @@ PUT /my_source_index/_settings
<1> Removes replica shards for the index.
<2> Relocates the index's shards to the `shrink_node_name` node.
See <<shard-allocation-filtering>>.
<3> Prevents write operations to this index. Metadata changes, such as deleting
the index, are still allowed.


It can take a while to relocate the source index. Progress can be tracked
with the <<cat-recovery,`_cat recovery` API>>, or the <<cluster-health,
`cluster health` API>> can be used to wait until all shards have relocated
with the `wait_for_no_relocating_shards` parameter.

You can then make the index read-only with the following request using the
<<add-index-block,add index block>> API:

[source,console]
--------------------------------------------------
PUT /my_source_index/_block/write
--------------------------------------------------
// TEST[continued]

[[shrink-index-api-desc]]
==== {api-description-title}
Expand Down
14 changes: 3 additions & 11 deletions docs/reference/indices/split-index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,23 +37,15 @@ POST /my-index-000001/_split/split-my-index-000001
** The index must be read-only.
** The <<cluster-health, cluster health>> status must be green.

You can do make an index read-only
with the following request:
You can do make an index read-only with the following request using the
<<add-index-block,add index block>> API:

[source,console]
--------------------------------------------------
PUT /my_source_index/_settings
{
"settings": {
"index.blocks.write": true <1>
}
}
PUT /my_source_index/_block/write
--------------------------------------------------
// TEST[s/^/PUT my_source_index\n/]

<1> Prevents write operations to this index while still allowing metadata
changes like deleting the index.

The current write index on a data stream cannot be split. In order to split
the current write index, the data stream must first be
<<data-streams-rollover,rolled over>> so that a new write index is created
Expand Down

0 comments on commit 9a049a1

Please sign in to comment.