<commit_before>[[cat-recovery]]
== cat recovery

The `recovery` command is a view of index shard recoveries, both on-going and previously
completed. It is a more compact view of the JSON <<indices-recovery,recovery>> API.

A recovery event occurs anytime an index shard moves to a different node in the cluster.
This can happen during a snapshot recovery, a change in replication level, node failure, or
on node startup. This last type is called a local store recovery and is the normal
way for shards to be loaded from disk when a node starts up.

As an example, here is what the recovery state of a cluster may look like when there
are no shards in transit from one node to another:

[source,js]
----------------------------------------------------------------------------
GET _cat/recovery?v
---------------------------------------------------------------------------
// CONSOLE
// TEST[setup:twitter]

The response of this request will be something like:

[source,js]
---------------------------------------------------------------------------
index   shard time type  stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
twitter 0     13ms store done  n/a         n/a         127.0.0.1   node-0      n/a        n/a      0     0               100%          13          0     0               100%          9928        0            0                      100.0%
---------------------------------------------------------------------------
// TESTRESPONSE[s/store/empty_store/]
// TESTRESPONSE[s/100%/0.0%/]
// TESTRESPONSE[s/9928/0/]
// TESTRESPONSE[s/13/\\d+/ _cat]

In the above case, the source and target nodes are the same because the recovery
type was store, i.e. they were read from local storage on node start.

Now let's see what a live recovery looks like. By increasing the replica count
of our index and bringing another node online to host the replicas, we can see
what a live shard recovery looks like.

[source,js]
----------------------------------------------------------------------------
GET _cat/recovery?v&h=i,s,t,ty,st,shost,thost,f,fp,b,bp<commit_msg>Docs: Be ok with long recovery times<commit_after>[[cat-recovery]]
== cat recovery

The `recovery` command is a view of index shard recoveries, both on-going and previously
completed. It is a more compact view of the JSON <<indices-recovery,recovery>> API.

A recovery event occurs anytime an index shard moves to a different node in the cluster.
This can happen during a snapshot recovery, a change in replication level, node failure, or
on node startup. This last type is called a local store recovery and is the normal
way for shards to be loaded from disk when a node starts up.

As an example, here is what the recovery state of a cluster may look like when there
are no shards in transit from one node to another:

[source,js]
----------------------------------------------------------------------------
GET _cat/recovery?v
---------------------------------------------------------------------------
// CONSOLE
// TEST[setup:twitter]

The response of this request will be something like:

[source,js]
---------------------------------------------------------------------------
index   shard time type  stage source_host source_node target_host target_node repository snapshot files files_recovered files_percent files_total bytes bytes_recovered bytes_percent bytes_total translog_ops translog_ops_recovered translog_ops_percent
twitter 0     13ms store done  n/a         n/a         127.0.0.1   node-0      n/a        n/a      0     0               100%          13          0     0               100%          9928        0            0                      100.0%
---------------------------------------------------------------------------
// TESTRESPONSE[s/store/empty_store/]
// TESTRESPONSE[s/100%/0.0%/]
// TESTRESPONSE[s/9928/0/]
// TESTRESPONSE[s/13ms/\\d+m?s/]
// TESTRESPONSE[s/13/\\d+/ _cat]

In the above case, the source and target nodes are the same because the recovery
type was store, i.e. they were read from local storage on node start.

Now let's see what a live recovery looks like. By increasing the replica count
of our index and bringing another node online to host the replicas, we can see
what a live shard recovery looks like.

[source,js]
----------------------------------------------------------------------------
GET _cat/recovery?v&h=i,s,t,ty,st,shost,thost,f,fp,b,bp
{'fraction_non_alphanumeric': 0.22002635046113306, 'fraction_numerical': 0.019762845849802372, 'mean_word_length': 1.6857311320754718, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5145155', 'n_tokens_mistral': 1185, 'n_tokens_neox': 1129, 'n_words': 500}