44<titleabbrev>Index recovery</titleabbrev>
55++++
66
7- The index recovery API provides insight into on-going index shard recoveries.
8- Recovery status may be reported for specific indices, or cluster-wide.
97
10- For example, the following command would show recovery information for the indices "index1" and "index2".
8+ Returns information about ongoing and completed shard recoveries.
9+
10+ [source,console]
11+ ----
12+ GET /twitter/_recovery
13+ ----
14+ // TEST[setup:twitter]
15+
16+
17+ [[index-recovery-api-request]]
18+ ==== {api-request-title}
19+
20+ `GET /<index>/_recovery`
21+
22+ `GET /_recovery`
23+
24+
25+ [[index-recovery-api-desc]]
26+ ==== {api-description-title}
27+
28+ Use the index recovery API
29+ to get information about ongoing and completed shard recoveries.
30+
31+ // tag::shard-recovery-desc[]
32+ Shard recovery is the process
33+ of syncing a replica shard from a primary shard.
34+ Upon completion,
35+ the replica shard is available for search.
36+
37+ include::{docdir}/glossary.asciidoc[tag=recovery-triggers]
38+
39+ // end::shard-recovery-desc[]
40+
41+ [[index-recovery-api-path-params]]
42+ ==== {api-path-parms-title}
43+
44+ include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
45+ +
46+ Use a value of `_all` to retrieve information for all indices in the cluster.
47+
48+
49+ [[index-recovery-api-query-params]]
50+ ==== {api-query-parms-title}
51+
52+ include::{docdir}/rest-api/common-parms.asciidoc[tag=active-only]
53+
54+ include::{docdir}/rest-api/common-parms.asciidoc[tag=detailed]
55+
56+ include::{docdir}/rest-api/common-parms.asciidoc[tag=index-query-parm]
57+
58+
59+ [[index-recovery-api-response-body]]
60+ ==== {api-response-body-title}
61+
62+ `id`::
63+ (Integer)
64+ ID of the shard.
65+
66+ `type`::
67+ +
68+ --
69+ (String)
70+ Recovery type.
71+ Returned values include:
72+
73+ `STORE`::
74+ The recovery is related to
75+ a node startup or failure.
76+ This type of recovery is called a local store recovery.
77+
78+ `SNAPSHOT`::
79+ The recovery is related to
80+ a <<restore-snapshot,snapshot restoration>>.
81+
82+ `REPLICA`::
83+ The recovery is related to
84+ a <<glossary-replica-shard,primary shard replication>>.
85+
86+ `RELOCATING`::
87+ The recovery is related to
88+ the relocation of a shard
89+ to a different node in the same cluster.
90+ --
91+
92+ `STAGE`::
93+ +
94+ --
95+ (String)
96+ Recovery stage.
97+ Returned values include:
98+
99+ `DONE`::
100+ Complete.
101+
102+ `FINALIZE`::
103+ Cleanup.
104+
105+ `INDEX`::
106+ Reading index metadata and copying bytes from source to destination.
107+
108+ `INIT`::
109+ Recovery has not started.
110+
111+ `START`::
112+ Starting the recovery process; opening the index for use.
113+
114+ `TRANSLOG`::
115+ Replaying transaction log .
116+ --
117+
118+ `primary`::
119+ (Boolean)
120+ If `true`,
121+ the shard is a primary shard.
122+
123+ `start_time`::
124+ (String)
125+ Timestamp of recovery start.
126+
127+ `stop_time`::
128+ (String)
129+ Timestamp of recovery finish.
130+
131+ `total_time_in_millis`::
132+ (String)
133+ Total time to recover shard in milliseconds.
134+
135+ `source`::
136+ +
137+ --
138+ (Object)
139+ Recovery source.
140+ This can include:
141+
142+ * A repository description if recovery is from a snapshot
143+ * A description of source node
144+ --
145+
146+ `target`::
147+ (Object)
148+ Destination node.
149+
150+ `index`::
151+ (Object)
152+ Statistics about physical index recovery.
153+
154+ `translog`::
155+ (Object)
156+ Statistics about translog recovery.
157+
158+ `start`::
159+ (Object)
160+ Statistics about time to open and start the index.
161+
162+
163+ [[index-recovery-api-example]]
164+ ==== {api-examples-title}
165+
166+
167+ [[index-recovery-api-multi-ex]]
168+ ===== Get recovery information for several indices
11169
12170[source,console]
13171--------------------------------------------------
14172GET index1,index2/_recovery?human
15173--------------------------------------------------
16174// TEST[s/^/PUT index1\nPUT index2\n/]
17175
18- To see cluster-wide recovery status simply leave out the index names.
19176
20- //////////////////////////
177+ [[index-recovery-api-all-ex]]
178+ ===== Get segment information for all indices
21179
180+ //////////////////////////
22181Here we create a repository and snapshot index1 in
23182order to restore it right after and prints out the
24183index recovery result.
@@ -61,7 +220,6 @@ POST /_snapshot/my_repository/snap_1/_restore?wait_for_completion=true
61220 }
62221}
63222--------------------------------------------------
64-
65223//////////////////////////
66224
67225[source,console]
@@ -70,7 +228,7 @@ GET /_recovery?human
70228--------------------------------------------------
71229// TEST[continued]
72230
73- Response :
231+ The API returns the following response :
74232
75233[source,console-result]
76234--------------------------------------------------
@@ -149,20 +307,28 @@ The TESTRESPONSE above replace all the fields values by the expected ones in the
149307because we don't really care about the field values but we want to check the fields names.
150308////
151309
152- The above response shows a single index recovering a single shard. In this case, the source of the recovery is a snapshot repository
153- and the target of the recovery is the node with name "my_es_node".
310+ This response includes information
311+ about a single index recovering a single shard.
312+ The source of the recovery is a snapshot repository
313+ and the target of the recovery is the `my_es_node` node.
314+
315+ The response also includes the number
316+ and percentage of files and bytes recovered.
154317
155- Additionally, the output shows the number and percent of files recovered, as well as the number and percent of bytes recovered.
156318
157- In some cases a higher level of detail may be preferable. Setting "detailed=true" will present a list of physical files in recovery.
319+ [[index-recovery-api-detailed-ex]]
320+ ===== Get detailed recovery information
321+
322+ To get a list of physical files in recovery,
323+ set the `detailed` query parameter to `true`.
158324
159325[source,console]
160326--------------------------------------------------
161327GET _recovery?human&detailed=true
162328--------------------------------------------------
163329// TEST[s/^/PUT index1\n{"settings": {"index.number_of_shards": 1}}\n/]
164330
165- Response :
331+ The API returns the following response :
166332
167333[source,console-result]
168334--------------------------------------------------
@@ -258,43 +424,22 @@ because we don't really care about the field values but we want to check the fie
258424It also removes the "details" part which is important in this doc but really hard to test.
259425////
260426
261- This response shows a detailed listing (truncated for brevity) of the actual files recovered and their sizes.
262-
263- Also shown are the timings in milliseconds of the various stages of recovery: index retrieval, translog replay, and index start time.
264-
265- Note that the above listing indicates that the recovery is in stage "done". All recoveries, whether on-going or complete, are kept in
266- cluster state and may be reported on at any time. Setting "active_only=true" will cause only on-going recoveries to be reported.
267-
268- Here is a complete list of options:
269-
270- [horizontal]
271- `detailed`:: Display a detailed view. This is primarily useful for viewing the recovery of physical index files. Default: false.
272- `active_only`:: Display only those recoveries that are currently on-going. Default: false.
273-
274- Description of output fields:
275-
276- [horizontal]
277- `id`:: Shard ID
278- `type`:: Recovery type:
279- * store
280- * snapshot
281- * replica
282- * relocating
283- `stage`:: Recovery stage:
284- * init: Recovery has not started
285- * index: Reading index meta-data and copying bytes from source to destination
286- * start: Starting the engine; opening the index for use
287- * translog: Replaying transaction log
288- * finalize: Cleanup
289- * done: Complete
290- `primary`:: True if shard is primary, false otherwise
291- `start_time`:: Timestamp of recovery start
292- `stop_time`:: Timestamp of recovery finish
293- `total_time_in_millis`:: Total time to recover shard in milliseconds
294- `source`:: Recovery source:
295- * repository description if recovery is from a snapshot
296- * description of source node otherwise
297- `target`:: Destination node
298- `index`:: Statistics about physical index recovery
299- `translog`:: Statistics about translog recovery
300- `start`:: Statistics about time to open and start the index
427+ The response includes a listing
428+ of any physical files recovered
429+ and their sizes.
430+
431+ The response also includes timings in milliseconds
432+ of the various stages of recovery:
433+
434+ * Index retrieval
435+ * Translog replay
436+ * Index start time
437+
438+ This response indicates the recovery is `done`.
439+ All recoveries,
440+ whether ongoing or complete,
441+ are kept in the cluster state
442+ and may be reported on at any time.
443+
444+ To only return information about ongoing recoveries,
445+ set the `active_only` query parameter to `true`.
0 commit comments