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

The `shards` command is the detailed view of what nodes contain which
shards.  It will tell you if it's a primary or replica, the number of
docs, the bytes it takes on disk, and the node where it's located.

Here we see a single index, with one primary shard and no replicas:

[source,js]
---------------------------------------------------------------------------
GET _cat/shards
---------------------------------------------------------------------------
// CONSOLE
// TEST[setup:twitter]

This will return

[source,js]
---------------------------------------------------------------------------
twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
---------------------------------------------------------------------------
// TESTRESPONSE[s/3014/\\d+/]
// TESTRESPONSE[s/31.1/\\d+(\.\\d+)?/]
// TESTRESPONSE[s/mb/.*/]
// TESTRESPONSE[s/192.168.56.10/.*/]
// TESTRESPONSE[s/H5dfFeA/node-0/ _cat]

[float]
[[index-pattern]]
=== Index pattern

If you have many shards, you may wish to limit which indices show up
in the output.  You can always do this with `grep`, but you can save
some bandwidth by supplying an index pattern to the end.

[source,js]
---------------------------------------------------------------------------
GET _cat/shards/twitt*
---------------------------------------------------------------------------
// CONSOLE
// TEST[setup:twitter]

Which will return the following

[source,js]
---------------------------------------------------------------------------
twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
---------------------------------------------------------------------------
// TESTRESPONSE[s/3014/\\d+/]
// TESTRESPONSE[s/31.1/\\d+\.\\d+/]
// TESTRESPONSE[s/mb/.*/]
// TESTRESPONSE[s/192.168.56.10/.*/]
// TESTRESPONSE[s/H5dfFeA/node-0/ _cat]


[float]
[[relocation]]
=== Relocation

Let's say you've checked your health and you see a relocating
shards.  Where are they from and where are they going?

[source,js]
---------------------------------------------------------------------------
GET _cat/shards
---------------------------------------------------------------------------
// CONSOLE
// TEST[skip:for now, relocation cannot be recreated]

A relocating shard will be shown as follows

[source,js]
---------------------------------------------------------------------------
twitter 0 p RELOCATING 3014 31.1mb 192.168.56.10 H5dfFeA -> -> 192.168.56.30 bGG90GE<commit_msg>Doc test: use propery regex for file size<commit_after>[[cat-shards]]
== cat shards

The `shards` command is the detailed view of what nodes contain which
shards.  It will tell you if it's a primary or replica, the number of
docs, the bytes it takes on disk, and the node where it's located.

Here we see a single index, with one primary shard and no replicas:

[source,js]
---------------------------------------------------------------------------
GET _cat/shards
---------------------------------------------------------------------------
// CONSOLE
// TEST[setup:twitter]

This will return

[source,js]
---------------------------------------------------------------------------
twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
---------------------------------------------------------------------------
// TESTRESPONSE[s/3014/\\d+/]
// TESTRESPONSE[s/31.1mb/\\d+(\.\\d+)?[kmg]?b/]
// TESTRESPONSE[s/192.168.56.10/.*/]
// TESTRESPONSE[s/H5dfFeA/node-0/ _cat]

[float]
[[index-pattern]]
=== Index pattern

If you have many shards, you may wish to limit which indices show up
in the output.  You can always do this with `grep`, but you can save
some bandwidth by supplying an index pattern to the end.

[source,js]
---------------------------------------------------------------------------
GET _cat/shards/twitt*
---------------------------------------------------------------------------
// CONSOLE
// TEST[setup:twitter]

Which will return the following

[source,js]
---------------------------------------------------------------------------
twitter 0 p STARTED 3014 31.1mb 192.168.56.10 H5dfFeA
---------------------------------------------------------------------------
// TESTRESPONSE[s/3014/\\d+/]
// TESTRESPONSE[s/31.1mb/\\d+(\.\\d+)?[kmg]?b/]
// TESTRESPONSE[s/192.168.56.10/.*/]
// TESTRESPONSE[s/H5dfFeA/node-0/ _cat]


[float]
[[relocation]]
=== Relocation

Let's say you've checked your health and you see a relocating
shards.  Where are they from and where are they going?

[source,js]
---------------------------------------------------------------------------
GET _cat/shards
---------------------------------------------------------------------------
// CONSOLE
// TEST[skip:for now, relocation cannot be recreated]

A relocating shard will be shown as follows

[source,js]
---------------------------------------------------------------------------
twitter 0 p RELOCATING 3014 31.1mb 192.168.56.10 H5dfFeA -> -> 192.168.56.30 bGG90GE
{'fraction_non_alphanumeric': 0.4257566524476945, 'fraction_numerical': 0.043469429209831406, 'mean_word_length': 1.0706476030277545, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 12, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2471784', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1294, 'n_words': 402}