Skip to content

Commit 3fabe5f

Browse files
committed
[DOCS] Reformat index stats API docs (#46322)
1 parent 7e16878 commit 3fabe5f

File tree

3 files changed

+253
-87
lines changed

3 files changed

+253
-87
lines changed

docs/reference/cluster/nodes-stats.asciidoc

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -113,36 +113,23 @@ include::{docdir}/rest-api/common-parms.asciidoc[tag=node-id]
113113
[[cluster-nodes-stats-api-query-params]]
114114
==== {api-query-parms-title}
115115

116-
`completion_fields`::
117-
(Optional, string) A comma-separated list of fields for `fielddata` and
118-
`suggest` index metric (supports wildcards).
116+
include::{docdir}/rest-api/common-parms.asciidoc[tag=completion-fields]
119117

120-
`fielddata_fields`::
121-
(Optional, string) A comma-separated list of fields for `fielddata` index
122-
metric (supports wildcards).
118+
include::{docdir}/rest-api/common-parms.asciidoc[tag=fielddata-fields]
123119

124-
`fields`::
125-
(Optional, string) A comma-separated list of fields for `fielddata` and
126-
`completion` index metric (supports wildcards).
120+
include::{docdir}/rest-api/common-parms.asciidoc[tag=fields]
127121

128-
`groups`::
129-
(Optional, string) A comma-separated list of search groups for `search`
130-
index metric.
122+
include::{docdir}/rest-api/common-parms.asciidoc[tag=groups]
131123

132-
`level`::
133-
(Optional, string) Returns indices stats aggregated at index, node or shard
134-
level. Supported options: `indices`, `node`, `shards`.
124+
include::{docdir}/rest-api/common-parms.asciidoc[tag=level]
135125

136126
`types`::
137127
(Optional, string) A comma-separated list of document types for the
138128
`indexing` index metric.
139129

140130
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
141131

142-
`include_segment_file_sizes`::
143-
(Optional, boolean) If `true`, the call reports the aggregated disk usage of
144-
each one of the Lucene index files (only applies if segment stats are
145-
requested). Defaults to `false`.
132+
include::{docdir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
146133

147134

148135
[[cluster-nodes-stats-api-response-body]]
Lines changed: 108 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,98 +1,138 @@
11
[[indices-stats]]
2-
=== Indices Stats
2+
=== Index stats API
3+
++++
4+
<titleabbrev>Index stats</titleabbrev>
5+
++++
36

4-
Indices level stats provide statistics on different operations happening
5-
on an index. The API provides statistics on the index level scope
6-
(though most stats can also be retrieved using node level scope).
7+
Returns statistics for an index.
78

8-
The following returns high level aggregation and index level stats for
9-
all indices:
9+
[source,console]
10+
----
11+
GET /twitter/_stats
12+
----
13+
// TEST[setup:twitter]
1014

11-
[source,js]
12-
--------------------------------------------------
13-
GET /_stats
14-
--------------------------------------------------
15-
// CONSOLE
1615

17-
Specific index stats can be retrieved using:
16+
[[index-stats-api-request]]
17+
==== {api-request-title}
1818

19-
[source,js]
20-
--------------------------------------------------
21-
GET /index1,index2/_stats
22-
--------------------------------------------------
23-
// CONSOLE
24-
// TEST[s/^/PUT index1\nPUT index2\n/]
19+
`GET /<index>/_stats/<index-metric>`
20+
21+
`GET /<index>/_stats`
22+
23+
`GET /_stats`
24+
25+
26+
[[index-stats-api-desc]]
27+
==== {api-description-title}
28+
29+
Use the index stats API to get high-level aggregation and statistics for an index.
30+
31+
By default,
32+
the returned statistics are index-level
33+
with `primaries` and `total` aggregations.
34+
`primaries` are the values for only the primary shards.
35+
`total` are the accumulated values for both primary and replica shards.
36+
37+
To get shard-level statistics,
38+
set the `level` parameter to `shards`.
39+
40+
[NOTE]
41+
====
42+
When moving to another node,
43+
the shard-level statistics for a shard are cleared.
44+
Although the shard
45+
is no longer part of the node,
46+
that node retains any node-level statistics
47+
to which the shard contributed.
48+
====
49+
50+
51+
[[index-stats-api-path-params]]
52+
==== {api-path-parms-title}
53+
54+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
55+
+
56+
To retrieve statistics for all indices,
57+
use a value of `_all` or `*` or omit this parameter.
2558

26-
By default, all stats are returned, returning only specific stats can be
27-
specified as well in the URI. Those stats can be any of:
59+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-metric]
2860

29-
[horizontal]
30-
`docs`:: The number of docs / deleted docs (docs not yet merged out).
31-
Note, affected by refreshing the index.
3261

33-
`store`:: The size of the index.
62+
[[index-stats-api-query-params]]
63+
==== {api-query-parms-title}
3464

35-
`indexing`:: Indexing statistics, can be combined with a comma
36-
separated list of `types` to provide document type level stats.
65+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
66+
+
67+
Defaults to `open`.
3768

38-
`get`:: Get statistics, including missing stats.
69+
include::{docdir}/rest-api/common-parms.asciidoc[tag=fields]
3970

40-
`search`:: Search statistics including suggest statistics.
41-
You can include statistics for custom groups by adding
42-
an extra `groups` parameter (search operations can be associated with one or more
43-
groups). The `groups` parameter accepts a comma separated list of group names.
44-
Use `_all` to return statistics for all groups.
71+
include::{docdir}/rest-api/common-parms.asciidoc[tag=completion-fields]
4572

46-
`segments`:: Retrieve the memory use of the open segments. Optionally, setting the `include_segment_file_sizes` flag, report the aggregated disk usage of each one of the Lucene index files.
73+
include::{docdir}/rest-api/common-parms.asciidoc[tag=fielddata-fields]
4774

48-
`completion`:: Completion suggest statistics.
49-
`fielddata`:: Fielddata statistics.
50-
`flush`:: Flush statistics.
51-
`merge`:: Merge statistics.
52-
`request_cache`:: <<shard-request-cache,Shard request cache>> statistics.
53-
`refresh`:: Refresh statistics.
54-
`warmer`:: Warmer statistics.
55-
`translog`:: Translog statistics.
75+
`forbid_closed_indices`::
76+
(Optional, boolean)
77+
If `true`, statistics are *not* collected from closed indices.
78+
Defaults to `true`.
5679

57-
Some statistics allow per field granularity which accepts a list
58-
comma-separated list of included fields. By default all fields are included:
80+
include::{docdir}/rest-api/common-parms.asciidoc[tag=groups]
5981

60-
[horizontal]
61-
`fields`::
82+
include::{docdir}/rest-api/common-parms.asciidoc[tag=level]
6283

63-
List of fields to be included in the statistics. This is used as the
64-
default list unless a more specific field list is provided (see below).
84+
include::{docdir}/rest-api/common-parms.asciidoc[tag=include-segment-file-sizes]
6585

66-
`completion_fields`::
86+
include::{docdir}/rest-api/common-parms.asciidoc[tag=include-unloaded-segments]
6787

68-
List of fields to be included in the Completion Suggest statistics.
6988

70-
`fielddata_fields`::
89+
[[index-stats-api-example]]
90+
==== {api-examples-title}
7191

72-
List of fields to be included in the Fielddata statistics.
7392

93+
[[index-stats-api-multiple-ex]]
94+
===== Get statistics for multiple indices
7495

75-
Here are some samples:
96+
[source,console]
97+
--------------------------------------------------
98+
GET /index1,index2/_stats
99+
--------------------------------------------------
100+
// TEST[s/^/PUT index1\nPUT index2\n/]
101+
102+
103+
[[index-stats-api-all-ex]]
104+
===== Get statistics for all indices
105+
106+
[source,console]
107+
--------------------------------------------------
108+
GET /_stats
109+
--------------------------------------------------
110+
// TEST[setup:twitter]
111+
112+
113+
[[index-stats-api-specific-stats-ex]]
114+
===== Get specific statistics
76115

77-
[source,js]
116+
The following request returns
117+
only the `merge` and `refresh` statistics
118+
for all indices.
119+
120+
[source,console]
78121
--------------------------------------------------
79-
# Get back stats for merge and refresh only for all indices
80122
GET /_stats/merge,refresh
81-
# Get back stats for type1 and type2 documents for the my_index index
82-
GET /my_index/_stats/indexing?types=type1,type2
83-
# Get back just search stats for group1 and group2
84-
GET /_stats/search?groups=group1,group2
85123
--------------------------------------------------
86-
// CONSOLE
87-
// TEST[s/^/PUT my_index\n/]
124+
// TEST[setup:twitter]
88125

89-
The stats returned are aggregated on the index level, with
90-
`primaries` and `total` aggregations, where `primaries` are the values for only the
91-
primary shards, and `total` are the accumulated values for both primary and replica shards.
92126

93-
In order to get back shard level stats, set the `level` parameter to `shards`.
127+
[[index-stats-api-specific-groups-ex]]
128+
===== Get statistics for specific search groups
94129

95-
Note, as shards move around the cluster, their stats will be cleared as
96-
they are created on other nodes. On the other hand, even though a shard
97-
"left" a node, that node will still retain the stats that shard
98-
contributed to.
130+
The following request returns
131+
only search statistics
132+
for the `group1` and `group2` search groups.
133+
134+
[source,console]
135+
--------------------------------------------------
136+
GET /_stats/search?groups=group1,group2
137+
--------------------------------------------------
138+
// TEST[setup:twitter]

0 commit comments

Comments
 (0)