Skip to content

Commit d5597c9

Browse files
committed
[DOCS] Reformat index segments API docs (#46345)
1 parent 3f5f028 commit d5597c9

File tree

3 files changed

+208
-93
lines changed

3 files changed

+208
-93
lines changed

docs/reference/cat/segments.asciidoc

+18-24
Original file line numberDiff line numberDiff line change
@@ -49,46 +49,40 @@ Valid columns are:
4949
(Default) IP address of the segment's shard, such as `127.0.1.1`.
5050

5151
`segment`::
52-
(Default) Name of the segment, such as `_0`. The segment name is derived from
53-
the segment generation and used internally to create file names in the directory
54-
of the shard.
52+
(Default)
53+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment]
5554

5655
`generation`::
57-
(Default) Generation number, such as `0`. {es} increments this generation number
58-
for each segment written. {es} then uses this number to derive the segment name.
56+
(Default)
57+
include::{docdir}/rest-api/common-parms.asciidoc[tag=generation]
5958

6059
`docs.count`::
61-
(Default) Number of non-deleted documents in the segment, such as `25`. This
62-
number is based on Lucene documents and may include documents from
63-
<<nested,nested>> fields.
60+
(Default)
61+
include::{docdir}/rest-api/common-parms.asciidoc[tag=docs-count]
6462

6563
`docs.deleted`::
66-
(Default) Number of deleted documents in the segment, such as `0`. This number
67-
is based on Lucene documents. {es} reclaims the disk space of deleted Lucene
68-
documents when a segment is merged.
64+
(Default)
65+
include::{docdir}/rest-api/common-parms.asciidoc[tag=docs-deleted]
6966

7067
`size`::
71-
(Default) Disk space used by the segment, such as `50kb`.
68+
(Default)
69+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment-size]
7270

7371
`size.memory`::
74-
(Default) Bytes of segment data stored in memory for efficient search, such as
75-
`1264`.
72+
(Default)
73+
include::{docdir}/rest-api/common-parms.asciidoc[tag=memory]
7674

7775
`committed`::
78-
(Default) If `true`, the segment is committed to disk. Segments committed to
79-
disk would survive a hard reboot.
80-
+
81-
If `false`, the data from uncommitted segments is also stored in the transaction
82-
log. {es} replays those changes on the next start.
76+
(Default)
77+
include::{docdir}/rest-api/common-parms.asciidoc[tag=committed]
8378

8479
`searchable`::
85-
(Default) If `true`, the segment is searchable.
86-
+
87-
If `false`, likely means the segment is written to disk but has not been
88-
<<docs-refresh,refreshed>>.
80+
(Default)
81+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment-search]
8982

9083
`version`::
91-
(Default) Version of Lucene used to write the segment.
84+
(Default)
85+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment-version]
9286

9387
`compound`::
9488
(Default) If `true`, the segment is stored in a compound file. This means Lucene
+121-65
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,136 @@
11
[[indices-segments]]
2-
=== Indices Segments
2+
=== Index segments API
3+
++++
4+
<titleabbrev>Index segments</titleabbrev>
5+
++++
36

4-
Provide low level segments information that a Lucene index (shard level)
5-
is built with. Allows to be used to provide more information on the
6-
state of a shard and an index, possibly optimization information, data
7-
"wasted" on deletes, and so on.
7+
Returns low-level information about the https://lucene.apache.org/core/[Lucene]
8+
segments in index shards.
89

9-
Endpoints include segments for a specific index:
10+
[source,console]
11+
----
12+
GET /twitter/_segments
13+
----
14+
// TEST[setup:twitter]
1015

11-
[source,js]
16+
17+
[[index-segments-api-request]]
18+
==== {api-request-title}
19+
20+
`GET /<index>/_segments`
21+
22+
`GET /_segments`
23+
24+
`GET /_cat/segments/<index>`
25+
26+
27+
[[index-segments-api-path-params]]
28+
==== {api-path-parms-title}
29+
30+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index]
31+
32+
33+
[[index-segments-api-query-params]]
34+
==== {api-query-parms-title}
35+
36+
include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
37+
38+
include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
39+
+
40+
Defaults to `open`.
41+
42+
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
43+
44+
`verbose`::
45+
experimental:[]
46+
(Optional, boolean)
47+
If `true`, the response includes detailed information
48+
about Lucene's memory usage.
49+
Defaults to `false`.
50+
51+
52+
[[index-segments-api-response-body]]
53+
==== {api-response-body-title}
54+
55+
`<segment>`::
56+
(String)
57+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment]
58+
59+
`generation`::
60+
(Integer)
61+
include::{docdir}/rest-api/common-parms.asciidoc[tag=generation]
62+
63+
`num_docs`::
64+
(Integer)
65+
include::{docdir}/rest-api/common-parms.asciidoc[tag=docs-count]
66+
67+
`deleted_docs`::
68+
(Integer)
69+
include::{docdir}/rest-api/common-parms.asciidoc[tag=docs-deleted]
70+
71+
`size_in_bytes`::
72+
(Integer)
73+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment-size]
74+
75+
`memory_in_bytes`::
76+
(Integer)
77+
include::{docdir}/rest-api/common-parms.asciidoc[tag=memory]
78+
79+
`committed`::
80+
(Boolean)
81+
include::{docdir}/rest-api/common-parms.asciidoc[tag=committed]
82+
83+
`search`::
84+
(Boolean)
85+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment-search]
86+
87+
`version`::
88+
(String)
89+
include::{docdir}/rest-api/common-parms.asciidoc[tag=segment-version]
90+
91+
`compound`::
92+
(Boolean)
93+
If `true`, Lucene merged all files from the segment
94+
into a single file to save file descriptors.
95+
96+
`attributes`::
97+
(Object)
98+
Contains information about whether high compression was enabled.
99+
100+
101+
[[index-segments-api-example]]
102+
==== {api-examples-title}
103+
104+
105+
===== Get segment information for a specific index
106+
107+
[source,console]
12108
--------------------------------------------------
13109
GET /test/_segments
14110
--------------------------------------------------
15-
// CONSOLE
16111
// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/]
17-
// TESTSETUP
18112

19-
For several indices:
20113

21-
[source,js]
114+
===== Get segment information for several indices
115+
116+
[source,console]
22117
--------------------------------------------------
23118
GET /test1,test2/_segments
24119
--------------------------------------------------
25-
// CONSOLE
26120
// TEST[s/^/PUT test1\nPUT test2\n/]
27121

28-
Or for all indices:
29122

30-
[source,js]
123+
===== Get segment information for all indices
124+
125+
[source,console]
31126
--------------------------------------------------
32127
GET /_segments
33128
--------------------------------------------------
34-
// CONSOLE
129+
// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/]
35130

36-
Response:
131+
The API returns the following response:
37132

38-
[source,js]
133+
[source,console-response]
39134
--------------------------------------------------
40135
{
41136
"_shards": ...
@@ -79,61 +174,23 @@ Response:
79174
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
80175
// TESTRESPONSE[s/7\.0\.0/$body.$_path/]
81176

82-
_0:: The key of the JSON document is the name of the segment. This name
83-
is used to generate file names: all files starting with this
84-
segment name in the directory of the shard belong to this segment.
85-
86-
generation:: A generation number that is basically incremented when needing to
87-
write a new segment. The segment name is derived from this
88-
generation number.
89-
90-
num_docs:: The number of non-deleted documents that are stored in this segment.
91-
92-
deleted_docs:: The number of deleted documents that are stored in this segment.
93-
It is perfectly fine if this number is greater than 0, space is
94-
going to be reclaimed when this segment gets merged.
95-
96-
size_in_bytes:: The amount of disk space that this segment uses, in bytes.
97-
98-
memory_in_bytes:: Segments need to store some data into memory in order to be
99-
searchable efficiently. This number returns the number of bytes
100-
that are used for that purpose. A value of -1 indicates that
101-
Elasticsearch was not able to compute this number.
102-
103-
committed:: Whether the segment has been sync'ed on disk. Segments that are
104-
committed would survive a hard reboot. No need to worry in case
105-
of false, the data from uncommitted segments is also stored in
106-
the transaction log so that Elasticsearch is able to replay
107-
changes on the next start.
108-
109-
search:: Whether the segment is searchable. A value of false would most
110-
likely mean that the segment has been written to disk but no
111-
refresh occurred since then to make it searchable.
112-
113-
version:: The version of Lucene that has been used to write this segment.
114-
115-
compound:: Whether the segment is stored in a compound file. When true, this
116-
means that Lucene merged all files from the segment in a single
117-
one in order to save file descriptors.
118-
119-
attributes:: Contains information about whether high compression was enabled
120177

121-
[float]
122-
==== Verbose mode
178+
===== Verbose mode
123179

124-
To add additional information that can be used for debugging, use the `verbose` flag.
180+
To add additional information that can be used for debugging,
181+
use the `verbose` flag.
125182

126-
NOTE: The format of the additional detail information is labelled as experimental in Lucene and it may change in the future.
183+
experimental::[]
127184

128-
[source,js]
185+
[source,console]
129186
--------------------------------------------------
130187
GET /test/_segments?verbose=true
131188
--------------------------------------------------
132-
// CONSOLE
189+
// TEST[continued]
133190

134-
Response:
191+
The API returns the following response:
135192

136-
[source,js]
193+
[source,console-response]
137194
--------------------------------------------------
138195
{
139196
...
@@ -159,5 +216,4 @@ Response:
159216
...
160217
}
161218
--------------------------------------------------
162-
// NOTCONSOLE
163-
//Response is too verbose to be fully shown in documentation, so we just show the relevant bit and don't test the response.
219+
// TESTRESPONSE[skip:Response is too verbose to be fully shown in documentation, so we just show the relevant bit and don't test the response.]

0 commit comments

Comments
 (0)