|
1 | 1 | [[cat-indices]]
|
2 | 2 | === cat indices
|
3 | 3 |
|
4 |
| -The `indices` command provides a cross-section of each index. This |
5 |
| -information *spans nodes*. For example: |
| 4 | +Returns high-level information about indices in a cluster. |
6 | 5 |
|
7 |
| -[source,js] |
8 |
| --------------------------------------------------- |
9 |
| -GET /_cat/indices/twi*?v&s=index |
10 |
| --------------------------------------------------- |
11 |
| -// CONSOLE |
12 |
| -// TEST[setup:huge_twitter] |
13 |
| -// TEST[s/^/PUT twitter2\n{"settings": {"number_of_replicas": 0}}\n/] |
14 | 6 |
|
15 |
| -Might respond with: |
| 7 | +[[cat-indices-api-request]] |
| 8 | +==== {api-request-title} |
16 | 9 |
|
17 |
| -[source,txt] |
18 |
| --------------------------------------------------- |
19 |
| -health status index uuid pri rep docs.count docs.deleted store.size pri.store.size |
20 |
| -yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb |
21 |
| -green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b |
22 |
| --------------------------------------------------- |
23 |
| -// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/] |
24 |
| -// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json] |
| 10 | +`GET /_cat/indices/{index}` |
25 | 11 |
|
26 |
| -We can tell quickly how many shards make up an index, the number of |
27 |
| -docs, deleted docs, primary store size, and total store size (all shards including replicas). |
28 |
| -All these exposed metrics come directly from Lucene APIs. |
29 | 12 |
|
30 |
| -*Notes:* |
| 13 | +[[cat-indices-api-desc]] |
| 14 | +==== {api-description-title} |
31 | 15 |
|
32 |
| -1. As the number of documents and deleted documents shown in this are at the lucene level, |
33 |
| -it includes all the hidden documents (e.g. from nested documents) as well. |
| 16 | +Use the cat indices API to get the following information for each index in a |
| 17 | +cluster: |
34 | 18 |
|
35 |
| -2. To get actual count of documents at the Elasticsearch level, the recommended way |
36 |
| -is to use either the <<cat-count>> or the <<search-count>> |
| 19 | +* Shard count |
| 20 | +* Document count |
| 21 | +* Deleted document count |
| 22 | +* Primary store size |
| 23 | +* Total store size of all shards, including shard replicas |
37 | 24 |
|
38 |
| -[float] |
39 |
| -[[pri-flag]] |
40 |
| -==== Primaries |
| 25 | +These metrics are retrieved directly from |
| 26 | +https://lucene.apache.org/core/[Lucene], which {es} uses internally to power |
| 27 | +indexing and search. As a result, all document counts include hidden |
| 28 | +<<nested,nested>> documents. |
41 | 29 |
|
42 |
| -The index stats by default will show them for all of an index's |
43 |
| -shards, including replicas. A `pri` flag can be supplied to enable |
44 |
| -the view of relevant stats in the context of only the primaries. |
| 30 | +To get an accurate count of {es} documents, use the <<cat-count,cat count>> or |
| 31 | +<<search-count,count>> APIs. |
45 | 32 |
|
46 |
| -[float] |
47 |
| -[[examples]] |
48 |
| -==== Examples |
49 | 33 |
|
50 |
| -Which indices are yellow? |
| 34 | +[[cat-indices-api-path-params]] |
| 35 | +==== {api-path-parms-title} |
51 | 36 |
|
52 |
| -[source,js] |
53 |
| --------------------------------------------------- |
54 |
| -GET /_cat/indices?v&health=yellow |
55 |
| --------------------------------------------------- |
56 |
| -// CONSOLE |
57 |
| -// TEST[continued] |
| 37 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=index] |
58 | 38 |
|
59 |
| -Which looks like: |
60 | 39 |
|
61 |
| -[source,txt] |
62 |
| --------------------------------------------------- |
63 |
| -health status index uuid pri rep docs.count docs.deleted store.size pri.store.size |
64 |
| -yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb |
65 |
| --------------------------------------------------- |
66 |
| -// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/] |
67 |
| -// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ/.+/ non_json] |
| 40 | +[[cat-indices-api-query-params]] |
| 41 | +==== {api-query-parms-title} |
68 | 42 |
|
69 |
| -Which index has the largest number of documents? |
| 43 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=bytes] |
70 | 44 |
|
71 |
| -[source,js] |
72 |
| --------------------------------------------------- |
73 |
| -GET /_cat/indices?v&s=docs.count:desc |
74 |
| --------------------------------------------------- |
75 |
| -// CONSOLE |
76 |
| -// TEST[continued] |
| 45 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=http-format] |
77 | 46 |
|
78 |
| -Which looks like: |
| 47 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-h] |
79 | 48 |
|
80 |
| -[source,txt] |
81 |
| --------------------------------------------------- |
82 |
| -health status index uuid pri rep docs.count docs.deleted store.size pri.store.size |
83 |
| -yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb |
84 |
| -green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b |
85 |
| --------------------------------------------------- |
86 |
| -// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/] |
87 |
| -// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json] |
| 49 | +`health`:: |
| 50 | ++ |
| 51 | +-- |
| 52 | +(Optional, string) Health status used to limit returned indices. Valid values |
| 53 | +are: |
88 | 54 |
|
89 |
| -How many merge operations have the shards for the `twitter` completed? |
| 55 | +* `green` |
| 56 | +* `yellow` |
| 57 | +* `red` |
90 | 58 |
|
91 |
| -[source,js] |
92 |
| --------------------------------------------------- |
93 |
| -GET /_cat/indices/twitter?pri&v&h=health,index,pri,rep,docs.count,mt |
94 |
| --------------------------------------------------- |
95 |
| -// CONSOLE |
96 |
| -// TEST[continued] |
| 59 | +By default, the response includes indices of any health status. |
| 60 | +-- |
97 | 61 |
|
98 |
| -Might look like: |
| 62 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=help] |
99 | 63 |
|
100 |
| -[source,txt] |
101 |
| --------------------------------------------------- |
102 |
| -health index pri rep docs.count mt pri.mt |
103 |
| -yellow twitter 1 1 1200 16 16 |
104 |
| --------------------------------------------------- |
105 |
| -// TESTRESPONSE[s/16/\\d+/ non_json] |
| 64 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments] |
106 | 65 |
|
107 |
| -How much memory is used per index? |
| 66 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=local] |
108 | 67 |
|
| 68 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=master-timeout] |
| 69 | + |
| 70 | +[[pri-flag]] |
| 71 | +`pri` (primary shards):: |
| 72 | +(Optional, boolean) If `true`, the response only includes information from |
| 73 | +primary shards. Defaults to `false`. |
| 74 | + |
| 75 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s] |
| 76 | + |
| 77 | +include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v] |
| 78 | + |
| 79 | + |
| 80 | +[[cat-indices-api-example]] |
| 81 | +==== {api-examples-title} |
| 82 | + |
| 83 | +[[examples]] |
109 | 84 | [source,js]
|
110 | 85 | --------------------------------------------------
|
111 |
| -GET /_cat/indices?v&h=i,tm&s=tm:desc |
| 86 | +GET /_cat/indices/twi*?v&s=index |
112 | 87 | --------------------------------------------------
|
113 | 88 | // CONSOLE
|
114 |
| -// TEST[continued] |
| 89 | +// TEST[setup:huge_twitter] |
| 90 | +// TEST[s/^/PUT twitter2\n{"settings": {"number_of_replicas": 0}}\n/] |
115 | 91 |
|
116 |
| -Might look like: |
| 92 | +The API returns the following response: |
117 | 93 |
|
118 | 94 | [source,txt]
|
119 | 95 | --------------------------------------------------
|
120 |
| -i tm |
121 |
| -twitter 8.1gb |
122 |
| -twitter2 30.5kb |
| 96 | +health status index uuid pri rep docs.count docs.deleted store.size pri.store.size |
| 97 | +yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb |
| 98 | +green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 260b 260b |
123 | 99 | --------------------------------------------------
|
124 | 100 | // TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
|
125 |
| -// TESTRESPONSE[non_json] |
| 101 | +// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json] |
0 commit comments