Recovery API

Introduced 1.0

The Recovery API provides information about any completed or ongoing shard recoveries for one or more indexes. If a data stream is listed, the API returns information about that data stream’s backing indexes.

Shard recovery involves creating a shard copy to restore a primary shard from a snapshot or to synchronize a replica shard. After the shard recovery process completes, the recovered shard becomes available for use in search and index operations.

Shard recovery occurs automatically in the following scenarios:

  • Node startup, known as a local store recovery
  • Replication of a primary shard
  • Relocation of a shard to a different node within the same cluster
  • Restoration of a snapshot
  • Clone, shrink, or split operations

The Recovery API reports solely on completed recoveries for shard copies presently stored in the cluster. It reports only the most recent recovery for each shard copy and does not include historical information about previous recoveries or information about recoveries of shard copies that no longer exist. Consequently, if a shard copy completes a recovery and is subsequently relocated to a different node, then the information about the original recovery is not displayed in the Recovery API.

Path and HTTP methods

  1. GET /_recovery
  2. GET /<index-name>/recovery/

Path parameters

ParameterData typeDescription
index-nameStringA comma-separated list of indexes, data streams, or index aliases to which the operation is applied. Supports wildcard expressions (). Use _all or to specify all indexes and data streams in a cluster.

Query parameters

All of the following query parameters are optional.

ParameterData typeDescription
active_onlyBooleanWhen true, the response only includes active shard recoveries. Default is false.
detailedBooleanWhen true, provides detailed information about shard recoveries. Default is false.
indexStringA comma-separated list or wildcard expression of index names used to limit the request.

Response fields

The API responds with the following information about the recovery shard.

ParameterData typeDescription
idIntegerThe ID of the shard.
typeStringThe recovery source for the shard. Returned values include:
- EMPTY_STORE: An empty store. Indicates a new primary shard or the forced allocation of an empty primary shard using the Cluster Reroute API.
- EXISTING_STORE: The store of an existing primary shard. Indicates that the recovery is related to node startup or the allocation of an existing primary shard.
- LOCAL_SHARDS: Shards belonging to another index on the same node. Indicates that the recovery is related to a clone, shrink, or split operation.
- PEER: A primary shard on another node. Indicates that the recovery is related to shard replication.
- SNAPSHOT: A snapshot. Indicates that the recovery is related to a snapshot restore operation.
STAGEStringThe recovery stage. Returned values can include:
- INIT: Recovery has not started.
- INDEX: Reading index metadata and copying bytes from the source to the destination.
- VERIFY_INDEX: Verifying the integrity of the index.
- TRANSLOG: Replaying the transaction log.
- FINALIZE: Cleanup.
- DONE: Complete.
primaryBooleanWhen true, the shard is a primary shard.
start_timeStringThe timestamp indicating when the recovery started.
stop_timeStringThe timestamp indicating when the recovery completed.
total_time_in_millisStringThe total amount of time taken to recover a shard, in milliseconds.
sourceObjectThe recovery source. This can include a description of the repository (if the recovery is from a snapshot) or a description of the source node.
targetObjectThe destination node.
indexObjectStatistics about the physical index recovery.
translogObjectStatistics about the translog recovery.
startObjectStatistics about the amount of time taken to open and start the index.

Example requests

The following examples demonstrate how to recover information using the Recovery API.

Recover information from several or all indexes

The following example request returns recovery information about several indexes in a human-readable format:

  1. GET index1,index2/_recovery?human

copy

The following example request returns recovery information about all indexes in a human-readable format:

  1. GET /_recovery?human

copy

Recover detailed information

The following example request returns detailed recovery information:

  1. GET _recovery?human&detailed=true

copy

Example response

The following response returns detailed recovery information about an index named shakespeare:

  1. {
  2. "shakespeare": {
  3. "shards": [
  4. {
  5. "id": 0,
  6. "type": "EXISTING_STORE",
  7. "stage": "DONE",
  8. "primary": true,
  9. "start_time": "2024-07-01T18:06:47.415Z",
  10. "start_time_in_millis": 1719857207415,
  11. "stop_time": "2024-07-01T18:06:47.538Z",
  12. "stop_time_in_millis": 1719857207538,
  13. "total_time": "123ms",
  14. "total_time_in_millis": 123,
  15. "source": {
  16. "bootstrap_new_history_uuid": false
  17. },
  18. "target": {
  19. "id": "uerS7REgRQCbBF3ImY8wOQ",
  20. "host": "172.18.0.3",
  21. "transport_address": "172.18.0.3:9300",
  22. "ip": "172.18.0.3",
  23. "name": "opensearch-node2"
  24. },
  25. "index": {
  26. "size": {
  27. "total": "17.8mb",
  28. "total_in_bytes": 18708764,
  29. "reused": "17.8mb",
  30. "reused_in_bytes": 18708764,
  31. "recovered": "0b",
  32. "recovered_in_bytes": 0,
  33. "percent": "100.0%"
  34. },
  35. "files": {
  36. "total": 7,
  37. "reused": 7,
  38. "recovered": 0,
  39. "percent": "100.0%",
  40. "details": [
  41. {
  42. "name": "_1.cfs",
  43. "length": "9.8mb",
  44. "length_in_bytes": 10325945,
  45. "reused": true,
  46. "recovered": "0b",
  47. "recovered_in_bytes": 0
  48. },
  49. {
  50. "name": "_0.cfe",
  51. "length": "479b",
  52. "length_in_bytes": 479,
  53. "reused": true,
  54. "recovered": "0b",
  55. "recovered_in_bytes": 0
  56. },
  57. {
  58. "name": "_0.si",
  59. "length": "333b",
  60. "length_in_bytes": 333,
  61. "reused": true,
  62. "recovered": "0b",
  63. "recovered_in_bytes": 0
  64. },
  65. {
  66. "name": "_1.cfe",
  67. "length": "479b",
  68. "length_in_bytes": 479,
  69. "reused": true,
  70. "recovered": "0b",
  71. "recovered_in_bytes": 0
  72. },
  73. {
  74. "name": "_1.si",
  75. "length": "333b",
  76. "length_in_bytes": 333,
  77. "reused": true,
  78. "recovered": "0b",
  79. "recovered_in_bytes": 0
  80. },
  81. {
  82. "name": "_0.cfs",
  83. "length": "7.9mb",
  84. "length_in_bytes": 8380790,
  85. "reused": true,
  86. "recovered": "0b",
  87. "recovered_in_bytes": 0
  88. },
  89. {
  90. "name": "segments_3",
  91. "length": "405b",
  92. "length_in_bytes": 405,
  93. "reused": true,
  94. "recovered": "0b",
  95. "recovered_in_bytes": 0
  96. }
  97. ]
  98. },
  99. "total_time": "6ms",
  100. "total_time_in_millis": 6,
  101. "source_throttle_time": "-1",
  102. "source_throttle_time_in_millis": 0,
  103. "target_throttle_time": "-1",
  104. "target_throttle_time_in_millis": 0
  105. },
  106. "translog": {
  107. "recovered": 0,
  108. "total": 0,
  109. "percent": "100.0%",
  110. "total_on_start": 0,
  111. "total_time": "113ms",
  112. "total_time_in_millis": 113
  113. },
  114. "verify_index": {
  115. "check_index_time": "0s",
  116. "check_index_time_in_millis": 0,
  117. "total_time": "0s",
  118. "total_time_in_millis": 0
  119. }
  120. },
  121. {
  122. "id": 0,
  123. "type": "PEER",
  124. "stage": "DONE",
  125. "primary": false,
  126. "start_time": "2024-07-01T18:06:47.693Z",
  127. "start_time_in_millis": 1719857207693,
  128. "stop_time": "2024-07-01T18:06:47.744Z",
  129. "stop_time_in_millis": 1719857207744,
  130. "total_time": "50ms",
  131. "total_time_in_millis": 50,
  132. "source": {
  133. "id": "uerS7REgRQCbBF3ImY8wOQ",
  134. "host": "172.18.0.3",
  135. "transport_address": "172.18.0.3:9300",
  136. "ip": "172.18.0.3",
  137. "name": "opensearch-node2"
  138. },
  139. "target": {
  140. "id": "HFYKietmTO6Ud9COgP0k9Q",
  141. "host": "172.18.0.2",
  142. "transport_address": "172.18.0.2:9300",
  143. "ip": "172.18.0.2",
  144. "name": "opensearch-node1"
  145. },
  146. "index": {
  147. "size": {
  148. "total": "0b",
  149. "total_in_bytes": 0,
  150. "reused": "0b",
  151. "reused_in_bytes": 0,
  152. "recovered": "0b",
  153. "recovered_in_bytes": 0,
  154. "percent": "0.0%"
  155. },
  156. "files": {
  157. "total": 0,
  158. "reused": 0,
  159. "recovered": 0,
  160. "percent": "0.0%",
  161. "details": []
  162. },
  163. "total_time": "1ms",
  164. "total_time_in_millis": 1,
  165. "source_throttle_time": "-1",
  166. "source_throttle_time_in_millis": 0,
  167. "target_throttle_time": "-1",
  168. "target_throttle_time_in_millis": 0
  169. },
  170. "translog": {
  171. "recovered": 0,
  172. "total": 0,
  173. "percent": "100.0%",
  174. "total_on_start": -1,
  175. "total_time": "42ms",
  176. "total_time_in_millis": 42
  177. },
  178. "verify_index": {
  179. "check_index_time": "0s",
  180. "check_index_time_in_millis": 0,
  181. "total_time": "0s",
  182. "total_time_in_millis": 0
  183. }
  184. }
  185. ]
  186. }
  187. }