2013-08-28 19:24:34 -04:00
|
|
|
[[indices-segments]]
|
2019-09-05 08:33:17 -04:00
|
|
|
=== Index segments API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Index segments</titleabbrev>
|
|
|
|
++++
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
Returns low-level information about the https://lucene.apache.org/core/[Lucene]
|
2020-07-13 09:05:03 -04:00
|
|
|
segments in index shards. For data streams, the API returns information about
|
|
|
|
the stream's backing indices.
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
[source,console]
|
|
|
|
----
|
2020-07-31 09:51:47 -04:00
|
|
|
GET /my-index-000001/_segments
|
2019-09-05 08:33:17 -04:00
|
|
|
----
|
2020-07-31 09:51:47 -04:00
|
|
|
// TEST[setup:my_index]
|
2013-08-28 19:24:34 -04:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
[[index-segments-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
`GET /<target>/_segments`
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`GET /_segments`
|
|
|
|
|
|
|
|
|
|
|
|
[[index-segments-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
`<target>`::
|
|
|
|
(Optional, string)
|
|
|
|
Comma-separated list of data streams, indices, and index aliases used to limit
|
|
|
|
the request. Wildcard expressions (`*`) are supported.
|
|
|
|
+
|
|
|
|
To target all data streams and indices in a cluster, omit this parameter or use
|
|
|
|
`_all` or `*`.
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[index-segments-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-09-05 08:33:17 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-09-05 08:33:17 -04:00
|
|
|
+
|
|
|
|
Defaults to `open`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`verbose`::
|
|
|
|
experimental:[]
|
2020-10-29 10:05:57 -04:00
|
|
|
(Optional, Boolean)
|
2019-09-05 08:33:17 -04:00
|
|
|
If `true`, the response includes detailed information
|
|
|
|
about Lucene's memory usage.
|
|
|
|
Defaults to `false`.
|
|
|
|
|
|
|
|
|
|
|
|
[[index-segments-api-response-body]]
|
|
|
|
==== {api-response-body-title}
|
|
|
|
|
|
|
|
`<segment>`::
|
Deprecate REST access to System Indices (#63274) (Original #60945)
This PR adds deprecation warnings when accessing System Indices via the REST layer. At this time, these warnings are only enabled for Snapshot builds by default, to allow projects external to Elasticsearch additional time to adjust their access patterns.
Deprecation warnings will be triggered by all REST requests which access registered System Indices, except for purpose-specific APIs which access System Indices as an implementation detail a few specific APIs which will continue to allow access to system indices by default:
- `GET _cluster/health`
- `GET {index}/_recovery`
- `GET _cluster/allocation/explain`
- `GET _cluster/state`
- `POST _cluster/reroute`
- `GET {index}/_stats`
- `GET {index}/_segments`
- `GET {index}/_shard_stores`
- `GET _cat/[indices,aliases,health,recovery,shards,segments]`
Deprecation warnings for accessing system indices take the form:
```
this request accesses system indices: [.some_system_index], but in a future major version, direct access to system indices will be prevented by default
```
2020-10-06 15:41:40 -04:00
|
|
|
(String)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`generation`::
|
|
|
|
(Integer)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=generation]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`num_docs`::
|
|
|
|
(Integer)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=docs-count]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`deleted_docs`::
|
|
|
|
(Integer)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=docs-deleted]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`size_in_bytes`::
|
|
|
|
(Integer)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment-size]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`memory_in_bytes`::
|
|
|
|
(Integer)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=memory]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
Deprecate REST access to System Indices (#63274) (Original #60945)
This PR adds deprecation warnings when accessing System Indices via the REST layer. At this time, these warnings are only enabled for Snapshot builds by default, to allow projects external to Elasticsearch additional time to adjust their access patterns.
Deprecation warnings will be triggered by all REST requests which access registered System Indices, except for purpose-specific APIs which access System Indices as an implementation detail a few specific APIs which will continue to allow access to system indices by default:
- `GET _cluster/health`
- `GET {index}/_recovery`
- `GET _cluster/allocation/explain`
- `GET _cluster/state`
- `POST _cluster/reroute`
- `GET {index}/_stats`
- `GET {index}/_segments`
- `GET {index}/_shard_stores`
- `GET _cat/[indices,aliases,health,recovery,shards,segments]`
Deprecation warnings for accessing system indices take the form:
```
this request accesses system indices: [.some_system_index], but in a future major version, direct access to system indices will be prevented by default
```
2020-10-06 15:41:40 -04:00
|
|
|
`committed`::
|
2019-09-05 08:33:17 -04:00
|
|
|
(Boolean)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=committed]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`search`::
|
|
|
|
(Boolean)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment-search]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`version`::
|
|
|
|
(String)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=segment-version]
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
`compound`::
|
|
|
|
(Boolean)
|
|
|
|
If `true`, Lucene merged all files from the segment
|
|
|
|
into a single file to save file descriptors.
|
|
|
|
|
|
|
|
`attributes`::
|
|
|
|
(Object)
|
|
|
|
Contains information about whether high compression was enabled.
|
|
|
|
|
|
|
|
|
|
|
|
[[index-segments-api-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
===== Get segment information for a specific data stream or index
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
[source,console]
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /test/_segments
|
2013-08-28 19:24:34 -04:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/]
|
|
|
|
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
===== Get segment information for several data streams and indices
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
[source,console]
|
2017-08-28 05:23:09 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /test1,test2/_segments
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[s/^/PUT test1\nPUT test2\n/]
|
|
|
|
|
|
|
|
|
2020-07-13 09:05:03 -04:00
|
|
|
===== Get segment information for all data streams and indices in a cluster
|
2019-09-05 08:33:17 -04:00
|
|
|
|
|
|
|
[source,console]
|
2017-08-28 05:23:09 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /_segments
|
|
|
|
--------------------------------------------------
|
2019-09-05 08:33:17 -04:00
|
|
|
// TEST[s/^/PUT test\n{"settings":{"number_of_shards":1, "number_of_replicas": 0}}\nPOST test\/test\?refresh\n{"test": "test"}\n/]
|
2014-02-21 05:53:53 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
The API returns the following response:
|
2014-02-21 05:53:53 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
[source,console-response]
|
2014-02-21 05:53:53 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2017-08-28 05:23:09 -04:00
|
|
|
"_shards": ...
|
|
|
|
"indices": {
|
|
|
|
"test": {
|
|
|
|
"shards": {
|
|
|
|
"0": [
|
|
|
|
{
|
|
|
|
"routing": {
|
|
|
|
"state": "STARTED",
|
|
|
|
"primary": true,
|
|
|
|
"node": "zDC_RorJQCao9xf9pg3Fvw"
|
|
|
|
},
|
|
|
|
"num_committed_segments": 0,
|
|
|
|
"num_search_segments": 1,
|
|
|
|
"segments": {
|
|
|
|
"_0": {
|
|
|
|
"generation": 0,
|
|
|
|
"num_docs": 1,
|
|
|
|
"deleted_docs": 0,
|
|
|
|
"size_in_bytes": 3800,
|
|
|
|
"memory_in_bytes": 1410,
|
|
|
|
"committed": false,
|
|
|
|
"search": true,
|
|
|
|
"version": "7.0.0",
|
|
|
|
"compound": true,
|
|
|
|
"attributes": {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-02-21 05:53:53 -05:00
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
// TESTRESPONSE[s/"_shards": \.\.\./"_shards": $body._shards,/]
|
|
|
|
// TESTRESPONSE[s/"node": "zDC_RorJQCao9xf9pg3Fvw"/"node": $body.$_path/]
|
|
|
|
// TESTRESPONSE[s/"attributes": \{[^}]*\}/"attributes": $body.$_path/]
|
|
|
|
// TESTRESPONSE[s/: (\-)?[0-9]+/: $body.$_path/]
|
|
|
|
// TESTRESPONSE[s/7\.0\.0/$body.$_path/]
|
2014-02-21 05:53:53 -05:00
|
|
|
|
2017-08-28 05:23:09 -04:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
===== Verbose mode
|
2014-12-19 04:04:28 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
To add additional information that can be used for debugging,
|
|
|
|
use the `verbose` flag.
|
2014-12-19 04:04:28 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
experimental::[]
|
2014-12-19 04:04:28 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
[source,console]
|
2014-12-19 04:04:28 -05:00
|
|
|
--------------------------------------------------
|
2017-08-28 05:23:09 -04:00
|
|
|
GET /test/_segments?verbose=true
|
2014-12-19 04:04:28 -05:00
|
|
|
--------------------------------------------------
|
2019-09-05 08:33:17 -04:00
|
|
|
// TEST[continued]
|
2014-12-19 04:04:28 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
The API returns the following response:
|
2014-12-19 04:04:28 -05:00
|
|
|
|
2019-09-05 08:33:17 -04:00
|
|
|
[source,console-response]
|
2014-12-19 04:04:28 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
2020-07-21 15:49:58 -04:00
|
|
|
...
|
|
|
|
"_0": {
|
|
|
|
...
|
|
|
|
"ram_tree": [
|
|
|
|
{
|
|
|
|
"description": "postings [PerFieldPostings(format=1)]",
|
|
|
|
"size_in_bytes": 2696,
|
|
|
|
"children": [
|
|
|
|
{
|
|
|
|
"description": "format 'Lucene50_0' ...",
|
|
|
|
"size_in_bytes": 2608,
|
|
|
|
"children" :[ ... ]
|
|
|
|
},
|
2014-12-19 04:04:28 -05:00
|
|
|
...
|
2020-07-21 15:49:58 -04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
...
|
|
|
|
]
|
|
|
|
|
|
|
|
}
|
|
|
|
...
|
2014-12-19 04:04:28 -05:00
|
|
|
}
|
2016-01-28 07:32:12 -05:00
|
|
|
--------------------------------------------------
|
2019-09-05 08:33:17 -04:00
|
|
|
// 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.]
|