1
1
[[indices-segments]]
2
- === Indices Segments
2
+ === Index segments API
3
+ ++++
4
+ <titleabbrev>Index segments</titleabbrev>
5
+ ++++
3
6
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.
8
9
9
- Endpoints include segments for a specific index:
10
+ [source,console]
11
+ ----
12
+ GET /twitter/_segments
13
+ ----
14
+ // TEST[setup:twitter]
10
15
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]
12
108
--------------------------------------------------
13
109
GET /test/_segments
14
110
--------------------------------------------------
15
- // CONSOLE
16
111
// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/]
17
- // TESTSETUP
18
112
19
- For several indices:
20
113
21
- [source,js]
114
+ ===== Get segment information for several indices
115
+
116
+ [source,console]
22
117
--------------------------------------------------
23
118
GET /test1,test2/_segments
24
119
--------------------------------------------------
25
- // CONSOLE
26
120
// TEST[s/^/PUT test1\nPUT test2\n/]
27
121
28
- Or for all indices:
29
122
30
- [source,js]
123
+ ===== Get segment information for all indices
124
+
125
+ [source,console]
31
126
--------------------------------------------------
32
127
GET /_segments
33
128
--------------------------------------------------
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/]
35
130
36
- Response :
131
+ The API returns the following response :
37
132
38
- [source,js ]
133
+ [source,console-response ]
39
134
--------------------------------------------------
40
135
{
41
136
"_shards": ...
@@ -79,61 +174,23 @@ Response:
79
174
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
80
175
// TESTRESPONSE[s/7\.0\.0/$body.$_path/]
81
176
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
120
177
121
- [float]
122
- ==== Verbose mode
178
+ ===== Verbose mode
123
179
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.
125
182
126
- NOTE: The format of the additional detail information is labelled as experimental in Lucene and it may change in the future.
183
+ experimental::[]
127
184
128
- [source,js ]
185
+ [source,console ]
129
186
--------------------------------------------------
130
187
GET /test/_segments?verbose=true
131
188
--------------------------------------------------
132
- // CONSOLE
189
+ // TEST[continued]
133
190
134
- Response :
191
+ The API returns the following response :
135
192
136
- [source,js ]
193
+ [source,console-response ]
137
194
--------------------------------------------------
138
195
{
139
196
...
@@ -159,5 +216,4 @@ Response:
159
216
...
160
217
}
161
218
--------------------------------------------------
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