Skip to content

Commit 9bf8f33

Browse files
authored
[DOCS] Reformat split index API docs (#46713) (#47580)
1 parent def0ee8 commit 9bf8f33

File tree

2 files changed

+113
-67
lines changed

2 files changed

+113
-67
lines changed

docs/reference/indices/split-index.asciidoc

Lines changed: 100 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,60 @@
44
<titleabbrev>Split index</titleabbrev>
55
++++
66

7+
Splits an existing index into a new index with more primary shards.
8+
9+
[source,js]
10+
----
11+
POST /twitter/_split/split-twitter-index
12+
{
13+
"settings": {
14+
"index.number_of_shards": 2
15+
}
16+
}
17+
----
18+
// CONSOLE
19+
// TEST[s/^/PUT twitter\n{"settings":{"blocks.write":true}}\n/]
20+
21+
22+
[[split-index-api-request]]
23+
==== {api-request-title}
24+
25+
`POST /<index>/_shrink/<target-index>`
26+
27+
`PUT /<index>/_shrink/<target-index>`
28+
29+
30+
[[split-index-api-prereqs]]
31+
==== {api-prereq-title}
32+
33+
34+
Before you can split an index:
35+
36+
* The index must be read-only.
37+
* The <<cluster-health, cluster health>> status must be green.
38+
39+
You can do make an index read-only
40+
with the following request:
41+
42+
[source,js]
43+
--------------------------------------------------
44+
PUT /my_source_index/_settings
45+
{
46+
"settings": {
47+
"index.blocks.write": true <1>
48+
}
49+
}
50+
--------------------------------------------------
51+
// CONSOLE
52+
// TEST[s/^/PUT my_source_index\n/]
53+
54+
<1> Prevents write operations to this index while still allowing metadata
55+
changes like deleting the index.
56+
57+
58+
[[split-index-api-desc]]
59+
==== {api-description-title}
60+
761
The split index API allows you to split an existing index into a new index,
862
where each original primary shard is split into two or more primary shards in
963
the new index.
@@ -34,27 +88,28 @@ index may by split into an arbitrary number of shards greater than 1. The
3488
properties of the default number of routing shards will then apply to the
3589
newly split index.
3690

37-
[float]
38-
==== How does splitting work?
3991

40-
Splitting works as follows:
92+
[[how-split-works]]
93+
===== How splitting works
4194

42-
* First, it creates a new target index with the same definition as the source
95+
A split operation:
96+
97+
. Creates a new target index with the same definition as the source
4398
index, but with a larger number of primary shards.
4499

45-
* Then it hard-links segments from the source index into the target index. (If
100+
. Hard-links segments from the source index into the target index. (If
46101
the file system doesn't support hard-linking, then all segments are copied
47102
into the new index, which is a much more time consuming process.)
48103

49-
* Once the low level files are created all documents will be `hashed` again to delete
104+
. Hashes all documents again, after low level files are created, to delete
50105
documents that belong to a different shard.
51106

52-
* Finally, it recovers the target index as though it were a closed index which
107+
. Recovers the target index as though it were a closed index which
53108
had just been re-opened.
54109

55-
[float]
110+
56111
[[incremental-resharding]]
57-
==== Why doesn't Elasticsearch support incremental resharding?
112+
===== Why doesn't Elasticsearch support incremental resharding?
58113

59114
Going from `N` shards to `N+1` shards, aka. incremental resharding, is indeed a
60115
feature that is supported by many key-value stores. Adding a new shard and
@@ -83,51 +138,16 @@ covers both the old and the new index for read operations. Assuming that the
83138
old and new indices have respectively +M+ and +N+ shards, this has no overhead
84139
compared to searching an index that would have +M+N+ shards.
85140

86-
[float]
87-
==== Preparing an index for splitting
88-
89-
Create a new index:
90-
91-
[source,js]
92-
--------------------------------------------------
93-
PUT my_source_index
94-
{
95-
"settings": {
96-
"index.number_of_shards" : 1
97-
}
98-
}
99-
--------------------------------------------------
100-
// CONSOLE
101141

102-
In order to split an index, the index must be marked as read-only,
103-
and have <<cluster-health,health>> `green`.
104-
105-
This can be achieved with the following request:
106-
107-
[source,js]
108-
--------------------------------------------------
109-
PUT /my_source_index/_settings
110-
{
111-
"settings": {
112-
"index.blocks.write": true <1>
113-
}
114-
}
115-
--------------------------------------------------
116-
// CONSOLE
117-
// TEST[continued]
118-
119-
<1> Prevents write operations to this index while still allowing metadata
120-
changes like deleting the index.
121-
122-
[float]
123-
==== Splitting an index
142+
[[split-index]]
143+
===== Split an index
124144

125145
To split `my_source_index` into a new index called `my_target_index`, issue
126146
the following request:
127147

128148
[source,js]
129149
--------------------------------------------------
130-
POST my_source_index/_split/my_target_index
150+
POST /my_source_index/_split/my_target_index
131151
{
132152
"settings": {
133153
"index.number_of_shards": 2
@@ -162,7 +182,7 @@ and accepts `settings` and `aliases` parameters for the target index:
162182

163183
[source,js]
164184
--------------------------------------------------
165-
POST my_source_index/_split/my_target_index
185+
POST /my_source_index/_split/my_target_index
166186
{
167187
"settings": {
168188
"index.number_of_shards": 5 <1>
@@ -181,8 +201,9 @@ POST my_source_index/_split/my_target_index
181201

182202
NOTE: Mappings may not be specified in the `_split` request.
183203

184-
[float]
185-
==== Monitoring the split process
204+
205+
[[monitor-split]]
206+
===== Monitor the split process
186207

187208
The split process can be monitored with the <<cat-recovery,`_cat recovery`
188209
API>>, or the <<cluster-health, `cluster health` API>> can be used to wait
@@ -200,9 +221,36 @@ split process begins. When the split operation completes, the shard will
200221
become `active`. At that point, Elasticsearch will try to allocate any
201222
replicas and may decide to relocate the primary shard to another node.
202223

203-
[float]
204-
==== Wait For Active Shards
224+
225+
[[split-wait-active-shards]]
226+
===== Wait for active shards
205227

206228
Because the split operation creates a new index to split the shards to,
207229
the <<create-index-wait-for-active-shards,wait for active shards>> setting
208230
on index creation applies to the split index action as well.
231+
232+
233+
[[split-index-api-path-params]]
234+
==== {api-path-parms-title}
235+
236+
`<index>`::
237+
(Required, string)
238+
Name of the source index to split.
239+
240+
include::{docdir}/rest-api/common-parms.asciidoc[tag=target-index]
241+
242+
243+
[[split-index-api-query-params]]
244+
==== {api-query-parms-title}
245+
246+
include::{docdir}/rest-api/common-parms.asciidoc[tag=wait_for_active_shards]
247+
248+
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
249+
250+
251+
[[split-index-api-request-body]]
252+
==== {api-request-body-title}
253+
254+
include::{docdir}/rest-api/common-parms.asciidoc[tag=target-index-aliases]
255+
256+
include::{docdir}/rest-api/common-parms.asciidoc[tag=target-index-settings]

docs/reference/rest-api/common-parms.asciidoc

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,12 @@ tag::aliases[]
3131
index. See <<indices-aliases>>.
3232
end::aliases[]
3333

34-
tag::index-alias-filter[]
35-
<<query-dsl-bool-query, Filter query>>
36-
used to limit the index alias.
37-
+
38-
If specified,
39-
the index alias only applies to documents returned by the filter.
40-
end::index-alias-filter[]
34+
tag::target-index-aliases[]
35+
`aliases`::
36+
(Optional, <<indices-aliases,alias object>>)
37+
Index aliases which include the target index.
38+
See <<indices-aliases>>.
39+
end::target-index-aliases[]
4140

4241
tag::allow-no-indices[]
4342
`allow_no_indices`::
@@ -136,14 +135,6 @@ Wildcard expressions are not accepted.
136135
--
137136
end::expand-wildcards[]
138137

139-
tag::index-alias-filter[]
140-
<<query-dsl-bool-query, Filter query>>
141-
used to limit the index alias.
142-
+
143-
If specified,
144-
the index alias only applies to documents returned by the filter.
145-
end::index-alias-filter[]
146-
147138
tag::fielddata-fields[]
148139
`fielddata_fields`::
149140
(Optional, string)
@@ -584,6 +575,13 @@ tag::settings[]
584575
options for the index. See <<index-modules-settings>>.
585576
end::settings[]
586577

578+
tag::target-index-settings[]
579+
`settings`::
580+
(Optional, <<index-modules-settings,index setting object>>)
581+
Configuration options for the target index.
582+
See <<index-modules-settings>>.
583+
end::target-index-settings[]
584+
587585
tag::segment-size[]
588586
Disk space used by the segment, such as `50kb`.
589587
end::segment-size[]

0 commit comments

Comments
 (0)