原文地址: https://www.elastic.co/guide/en/elasticsearch/reference/7.7/cat-segments.html, 原文档版权归 www.elastic.co 所有

cat segments APIedit

Returns low-level information about the Lucene segments in index shards, similar to the indices segments API.

Requestedit

GET /_cat/segments/<index>

GET /_cat/segments

Path parametersedit

<index>
(Optional, string) Comma-separated list or wildcard expression of index names used to limit the request.

Query parametersedit

bytes
(Optional, byte size units) Unit used to display byte values.
format
(Optional, string) Short version of the HTTP accept header. Valid values include JSON, YAML, etc.
h

(Optional, string) Comma-separated list of column names to display.

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:

index, i, idx
(Default) Name of the index, such as twitter.
shard, s, sh
(Default) Name of the shard.
prirep, p, pr, primaryOrReplica
(Default) Shard type. Returned values are primary or replica.
ip
(Default) IP address of the segment’s shard, such as 127.0.1.1.
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.
generation
(Default) Generation number, such as 0. Elasticsearch increments this generation number for each segment written. Elasticsearch then uses this number to derive the segment name. Generation number, such as 0. Elasticsearch increments this generation number for each segment written. Elasticsearch then uses this number to derive the segment name.
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 fields.
docs.deleted
(Default) Number of deleted documents in the segment, such as 0. This number is based on Lucene documents. Elasticsearch reclaims the disk space of deleted Lucene documents when a segment is merged.
size
(Default) Disk space used by the segment, such as 50kb.
size.memory

(Default) Bytes of segment data stored in memory for efficient search, such as 1264.

A value of -1 indicates Elasticsearch was unable to compute this number.

committed

(Default) If true, the segments is synced to disk. Segments that are synced can survive a hard reboot.

If 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.

searchable

(Default) If true, the segment is searchable.

If false, the segment has most likely been written to disk but needs a refresh to be searchable.

version
(Default) Version of Lucene used to write the segment.
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.
id
ID of the node, such as k0zy.
help
(Optional, boolean) If true, the response includes help information. Defaults to false.
s
(Optional, string) Comma-separated list of column names or column aliases used to sort the response.
v
(Optional, boolean) If true, the response includes column headings. Defaults to false.

Examplesedit

GET /_cat/segments?v

The API returns the following response:

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       8.5.1   true
test1 0     p      127.0.0.1 _0               0          1            0  3kb        2042 false     true       8.5.1   true