Get index segments

  • GET /{index}/_segments
  • GET /_segments
Auth

Get low-level information about the Lucene segments in index shards. For data streams, the API returns information about the stream's backing indices.

Required privileges

Index privileges monitor

Path parameters

index union string | string[] optional

Comma-separated list of data streams, indices, and aliases used to limit the request. Supports wildcards (*). To target all data streams and indices, omit this parameter or use * or _all.

Leave it out to use /_segments.

Query parameters

allow_no_indices boolean · default: true

A setting that does two separate checks on the index expression. If false, the request returns an error (1) if any wildcard expression (including _all and *) resolves to zero matching indices or (2) if the complete set of resolved indices, aliases or data streams is empty after all expressions are evaluated. If true, index expressions that resolve to no indices are allowed and the request returns an empty result.

expand_wildcards union oneOf · default: open

Type of index that wildcard patterns can match. If the request can target data streams, this argument determines whether wildcard expressions match hidden data streams. Supports comma-separated values, such as open,hidden.

Supported values include:

  • all: Match any data stream or index, including hidden ones.
  • open: Match open, non-hidden indices. Also matches any non-hidden data stream.
  • closed: Match closed, non-hidden indices. Also matches any non-hidden data stream. Data streams cannot be closed.
  • hidden: Match hidden data streams and hidden indices. Must be combined with open, closed, or both.
  • none: Wildcard expressions are not accepted.
Values: all open closed hidden none
ignore_unavailable boolean · default: false

If false, the request returns an error if it targets a concrete (non-wildcarded) index, alias, or data stream that is missing, closed, or otherwise unavailable. If true, unavailable concrete targets are silently ignored.

include_auto_calibration boolean · default: false

If true, the response includes the auto-calibration information of each segment, for the dense_vector fields that support auto-calibration.

vector_formats boolean · default: false

If true, the response includes the vector formats used by the fields of each segment, in attributes.

Response

application/json
indices map string to object required
<string> object
shards map string to oneOf required
<string> union oneOf
One of:
{} ShardsSegment[]
num_committed_segments number required
routing object required
node string required

The node ID of the node that holds the shard.

relocating_node string

The node ID of the node the shard is relocating to. Only returned while the shard is relocating.

primary boolean required

If true, the shard is a primary shard.

state string required

The state of the shard, such as STARTED or RELOCATING.

num_search_segments number required
segments map string to object required
<string> object
attributes map string to string

Contains information about whether high compression was enabled and per-field vector formats.

committed boolean required

If true, the segment 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.

compound boolean

If true, Lucene merged all files from the segment into a single file to save file descriptors.

deleted_docs number required

The number of deleted documents as reported by Lucene, which may be higher or lower than the number of delete operations you have performed. This number excludes deletes that were performed recently and do not yet belong to a segment. Deleted documents are cleaned up by the automatic merge process if it makes sense to do so. Also, Elasticsearch creates extra deleted documents to internally track the recent history of operations on a shard.

generation number required

Generation number, such as 0. Elasticsearch increments this generation number for each segment written then uses this number to derive the segment name.

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

merge_id string

The ID of the merge the segment is part of. Only returned while the segment is being merged.

size number | string

Disk space used by the segment.

size_in_bytes number required

Disk space used by the segment, in bytes.

num_docs number required

The number of documents as reported by Lucene. This excludes deleted documents and counts any nested documents separately from their parents. It also excludes documents which were indexed recently and do not yet belong to a segment.

version string

Version of Lucene used to write the segment.

auto_calibration map string to oneOf

The auto-calibration information of the segment, per dense_vector field that supports auto-calibration. Only returned when include_auto_calibration is true.

_shards object required
failed number required

The number of shards the operation or search attempted to run on but failed.

successful number required

The number of shards the operation or search succeeded on.

total number required

The number of shards the operation or search will run on overall.

skipped number