Skip to content

Commit 5ade756

Browse files
committed
[DOCS] Reformats cat indices API (#45239)
1 parent d8423f0 commit 5ade756

File tree

2 files changed

+72
-90
lines changed

2 files changed

+72
-90
lines changed

docs/reference/cat/indices.asciidoc

Lines changed: 64 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -1,125 +1,101 @@
11
[[cat-indices]]
22
=== cat indices
33

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.
65

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/]
146

15-
Might respond with:
7+
[[cat-indices-api-request]]
8+
==== {api-request-title}
169

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}`
2511

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.
2912

30-
*Notes:*
13+
[[cat-indices-api-desc]]
14+
==== {api-description-title}
3115

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:
3418

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
3724

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.
4129

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.
4532

46-
[float]
47-
[[examples]]
48-
==== Examples
4933

50-
Which indices are yellow?
34+
[[cat-indices-api-path-params]]
35+
==== {api-path-parms-title}
5136

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]
5838

59-
Which looks like:
6039

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}
6842

69-
Which index has the largest number of documents?
43+
include::{docdir}/rest-api/common-parms.asciidoc[tag=bytes]
7044

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]
7746

78-
Which looks like:
47+
include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-h]
7948

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:
8854

89-
How many merge operations have the shards for the `twitter` completed?
55+
* `green`
56+
* `yellow`
57+
* `red`
9058

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+
--
9761

98-
Might look like:
62+
include::{docdir}/rest-api/common-parms.asciidoc[tag=help]
9963

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]
10665

107-
How much memory is used per index?
66+
include::{docdir}/rest-api/common-parms.asciidoc[tag=local]
10867

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]]
10984
[source,js]
11085
--------------------------------------------------
111-
GET /_cat/indices?v&h=i,tm&s=tm:desc
86+
GET /_cat/indices/twi*?v&s=index
11287
--------------------------------------------------
11388
// CONSOLE
114-
// TEST[continued]
89+
// TEST[setup:huge_twitter]
90+
// TEST[s/^/PUT twitter2\n{"settings": {"number_of_replicas": 0}}\n/]
11591

116-
Might look like:
92+
The API returns the following response:
11793

11894
[source,txt]
11995
--------------------------------------------------
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
12399
--------------------------------------------------
124100
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
125-
// TESTRESPONSE[non_json]
101+
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json]

docs/reference/rest-api/common-parms.asciidoc

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html[HTTP accept header].
2222
Valid values include JSON, YAML, etc.
2323
end::http-format[]
2424

25+
tag::include-unloaded-segments[]
26+
`include_unloaded_segments`::
27+
(Optional, boolean) If `true`, the response includes information from segments
28+
that are **not** loaded into memory. Defaults to `false`.
29+
end::include-unloaded-segments[]
30+
2531
tag::index[]
2632
`{index}`::
27-
(Optional, string) Comma-separated list of index names used to limit returned
28-
information.
33+
(Optional, string) Comma-separated list or wildcard expression of index names
34+
used to limit the request.
2935
end::index[]
3036

3137
tag::local[]

0 commit comments

Comments
 (0)