Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Reformats cat segments API #45397

Merged
merged 2 commits into from
Aug 12, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
152 changes: 101 additions & 51 deletions docs/reference/cat/segments.asciidoc
Original file line number Diff line number Diff line change
@@ -1,73 +1,123 @@
[[cat-segments]]
=== cat segments

The `segments` command provides low level information about the segments
in the shards of an index. It provides information similar to the
link:indices-segments.html[_segments] endpoint. For example:
Returns low-level information about the https://lucene.apache.org/core/[Lucene]
segments in index shards, similar to the <<indices-segments, indices segments>>
API.

[source,js]
--------------------------------------------------
GET /_cat/segments?v
--------------------------------------------------
// CONSOLE
// TEST[s/^/PUT \/test\/test\/1?refresh\n{"test":"test"}\nPUT \/test1\/test\/1?refresh\n{"test":"test"}\n/]
[[cat-segments-api-request]]
==== {api-request-title}

might look like:
`GET /_cat/segments/{index}`

["source","txt",subs="attributes,callouts"]
--------------------------------------------------
index shard prirep ip segment generation docs.count docs.deleted size size.memory committed searchable version compound
test 0 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
test1 0 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
--------------------------------------------------
// TESTRESPONSE[s/3kb/\\d+(\\.\\d+)?[mk]?b/ s/2042/\\d+/ non_json]

The output shows information about index names and shard numbers in the first
two columns.
[[cat-segments-path-params]]
==== {api-path-parms-title}

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


[[cat-segments-query-params]]
==== {api-query-parms-title}

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

include::{docdir}/rest-api/common-parms.asciidoc[tag=http-format]

include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-h]
+
--
If you do not specify which columns to include, the API returns the default
columns in the order listed below. If you explicitly specify one or more
columns, it only returns the specified columns.

Valid columns are:

If you only want to get information about segments in one particular index,
you can add the index name in the URL, for example `/_cat/segments/test`. Also,
several indexes can be queried like `/_cat/segments/test,test1`
`index`, `i`, `idx`::
(Default) Name of the index, such as `twitter`.

`shard`, `s`, `sh`::
(Default) Name of the shard.

The following columns provide additional monitoring information:
`prirep`, `p`, `pr`, `primaryOrReplica`::
(Default) Shard type. Returned values are `primary` or `replica`.

prirep:: Whether this segment belongs to a primary or replica shard.
`ip`::
(Default) IP address of the segment's shard, such as `127.0.1.1`.

ip:: The ip address of the segment's shard.
`segment`::
(Default) Name of the segment, such as `_0`. The segment name is derived from
the segment generation and used internally to create file names in the directory
of the shard.

segment:: A segment name, derived from the segment generation. The name
is internally used to generate the file names in the directory
of the shard this segment belongs to.
`generation`::
(Default) Generation number, such as `0`. {es} increments this generation number
for each segment written. {es} then uses this number to derive the segment name.

generation:: The generation number is incremented with each segment that is written.
The name of the segment is derived from this generation number.
`docs.count`::
(Default) Number of non-deleted documents in the segment, such as `25`. This
number is based on Lucene documents and may include documents from
<<nested,nested>> fields.

`docs.deleted`::
(Default) Number of deleted documents in the segment, such as `0`. This number
is based on Lucene documents. {es} reclaims the disk space of deleted Lucene
documents when a segment is merged.

docs.count:: The number of non-deleted documents that are stored in this segment.
Note that these are Lucene documents, so the count will include hidden
documents (e.g. from nested types).
`size`::
(Default) Disk space used by the segment, such as `50kb`.

docs.deleted:: The number of deleted documents that are stored in this segment.
It is perfectly fine if this number is greater than 0, space is
going to be reclaimed when this segment gets merged.
`size.memory`::
(Default) Bytes of segment data stored in memory for efficient search, such as
`1264`.

size:: The amount of disk space that this segment uses.
`committed`::
(Default) If `true`, the segment is committed to disk. Segments committed to
disk would survive a hard reboot.
+
If `false`, the data from uncommitted segments is also stored in the transaction
log. {es} replays those changes on the next start.

size.memory:: Segments store some data into memory in order to be searchable efficiently.
This column shows the number of bytes in memory that are used.
`searchable`::
(Default) If `true`, the segment is searchable.
+
If `false`, likely means the segment is written to disk but has not been
<<docs-refresh,refreshed>>.

committed:: Whether the segment has been sync'ed on disk. Segments that are
committed would survive a hard reboot. No need to worry in case
of false, the data from uncommitted segments is also stored in
the transaction log so that Elasticsearch is able to replay
changes on the next start.
`version`::
(Default) Version of Lucene used to write the segment.

searchable:: True if the segment is searchable. A value of false would most
likely mean that the segment has been written to disk but no
refresh occurred since then to make it searchable.
`compound`::
(Default) If `true`, the segment is stored in a compound file. This means Lucene
merged all files from the segment in a single file to save file descriptors.

version:: The version of Lucene that has been used to write this segment.
`id`::
ID of the node, such as `k0zy`.
--

compound:: Whether the segment is stored in a compound file. When true, this
means that Lucene merged all files from the segment in a single
one in order to save file descriptors.
include::{docdir}/rest-api/common-parms.asciidoc[tag=help]

include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-s]

include::{docdir}/rest-api/common-parms.asciidoc[tag=cat-v]


[[cat-shards-api-example]]
==== {api-examples-title}

[source,js]
--------------------------------------------------
GET /_cat/segments?v
--------------------------------------------------
// CONSOLE
// TEST[s/^/PUT \/test\/test\/1?refresh\n{"test":"test"}\nPUT \/test1\/test\/1?refresh\n{"test":"test"}\n/]

The API returns the following response:

["source","txt",subs="attributes,callouts"]
--------------------------------------------------
index shard prirep ip segment generation docs.count docs.deleted size size.memory committed searchable version compound
test 0 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
test1 0 p 127.0.0.1 _0 0 1 0 3kb 2042 false true {lucene_version} true
--------------------------------------------------
// TESTRESPONSE[s/3kb/\\d+(\\.\\d+)?[mk]?b/ s/2042/\\d+/ non_json]