Get index statistics Generally available; Added in 1.3.0

GET /{index}/_stats/{metric}

All methods and paths for this operation:

GET /_stats

GET /{index}/_stats
GET /_stats/{metric}
GET /{index}/_stats/{metric}

For data streams, the API retrieves statistics for the stream's backing indices.

By default, the returned statistics are index-level with primaries and total aggregations. primaries are the values for only the primary shards. total are the accumulated values for both primary and replica shards.

To get shard-level statistics, set the level parameter to shards.

NOTE: When moving to another node, the shard-level statistics for a shard are cleared. Although the shard is no longer part of the node, that node retains any node-level statistics to which the shard contributed.

Required authorization

  • Index privileges: monitor

Path parameters

  • index string | array[string] Required

    A comma-separated list of index names; use _all or empty string to perform the operation on all indices

  • metric string | array[string]

    Comma-separated list of metrics used to limit the request.

    Supported values include:

    • _all: Return all statistics.
    • store: Size of the index in byte units.
    • indexing: Indexing statistics.
    • get: Get statistics, including missing stats.
    • search: Search statistics including suggest statistics. You can include statistics for custom groups by adding an extra groups parameter (search operations can be associated with one or more groups). The groups parameter accepts a comma-separated list of group names. Use _all to return statistics for all groups.
    • merge: Merge statistics.
    • flush: Flush statistics.
    • refresh: Refresh statistics.
    • query_cache: Query cache statistics.
    • fielddata: Fielddata statistics.
    • docs: Number of documents and deleted docs not yet merged out. Index refreshes can affect this statistic.
    • warmer: Index warming statistics.
    • completion: Completion suggester statistics.
    • segments: Memory use of all open segments. If the include_segment_file_sizes parameter is true, this metric includes the aggregated disk usage of each Lucene index file.
    • translog: Translog statistics.
    • request_cache: Shard request cache statistics.
    • recovery: Recovery statistics.
    • bulk: Bulk operations statistics.
    • shard_stats: Shard statistics, including the total number of shards.
    • mappings: Mapping statistics, including the total count and estimated overhead.
    • dense_vector: Total number of dense vectors indexed. Index refreshes can affect this statistic.
    • sparse_vector: Total number of sparse vectors indexed. Index refreshes can affect this statistic.

    Values are _all, store, indexing, get, search, merge, flush, refresh, query_cache, fielddata, docs, warmer, completion, segments, translog, request_cache, recovery, bulk, shard_stats, mappings, dense_vector, or sparse_vector.

Query parameters

  • completion_fields string | array[string]

    Comma-separated list or wildcard expressions of fields to include in fielddata and suggest statistics.

  • expand_wildcards string | array[string]

    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 are all, open, closed, hidden, or none.

  • fielddata_fields string | array[string]

    Comma-separated list or wildcard expressions of fields to include in fielddata statistics.

  • fields string | array[string]

    Comma-separated list or wildcard expressions of fields to include in the statistics.

  • forbid_closed_indices boolean

    If true, statistics are not collected from closed indices.

  • groups string | array[string]

    Comma-separated list of search groups to include in the search statistics.

  • include_segment_file_sizes boolean

    If true, the call reports the aggregated disk usage of each one of the Lucene index files (only applies if segment stats are requested).

  • include_unloaded_segments boolean

    If true, the response includes information from segments that are not loaded into memory.

  • level string

    Indicates whether statistics are aggregated at the cluster, indices, or shards level.

    Values are cluster, indices, or shards.

Responses

  • 200 application/json
    Hide response attributes Show response attributes object
    • indices object
      Hide indices attribute Show indices attribute object
      • * object Additional properties
        Hide * attributes Show * attributes object
        • primaries object
          Hide primaries attributes Show primaries attributes object
          • completion object

            Contains statistics about completions across all shards assigned to the node.

          • docs object

            Contains statistics about documents across all primary shards assigned to the node.

          • fielddata object

            Contains statistics about the field data cache across all shards assigned to the node.

          • flush object

            Contains statistics about flush operations for the node.

          • get object

            Contains statistics about get operations for the node.

          • indexing object

            Contains statistics about indexing operations for the node.

          • indices object Additional properties

            Contains statistics about indices operations for the node.

          • merges object

            Contains statistics about merge operations for the node.

          • query_cache object

            Contains statistics about the query cache across all shards assigned to the node.

          • recovery object

            Contains statistics about recovery operations for the node.

          • refresh object

            Contains statistics about refresh operations for the node.

          • request_cache object

            Contains statistics about the request cache across all shards assigned to the node.

          • segments object

            Contains statistics about segments across all shards assigned to the node.

          • store object

            Contains statistics about the size of shards assigned to the node.

          • translog object

            Contains statistics about transaction log operations for the node.

          • warmer object

            Contains statistics about index warming operations for the node.

          • bulk object
          • shard_stats object
        • shards object
          Hide shards attribute Show shards attribute object
          • * array[object] Additional properties
            Hide * attributes Show * attributes object
            • commit
            • completion
            • docs
            • fielddata
            • flush
            • get
            • indexing
            • mappings
            • merges
            • shard_path
            • query_cache
            • recovery
            • refresh
            • request_cache
            • retention_leases
            • routing
            • search
            • segments
            • seq_no
            • store
            • translog
            • warmer
            • bulk
            • shards object Generally available; Added in 7.15.0
            • shard_stats
            • indices
        • total object
          Hide total attributes Show total attributes object
          • completion object

            Contains statistics about completions across all shards assigned to the node.

          • docs object

            Contains statistics about documents across all primary shards assigned to the node.

          • fielddata object

            Contains statistics about the field data cache across all shards assigned to the node.

          • flush object

            Contains statistics about flush operations for the node.

          • get object

            Contains statistics about get operations for the node.

          • indexing object

            Contains statistics about indexing operations for the node.

          • indices object Additional properties

            Contains statistics about indices operations for the node.

          • merges object

            Contains statistics about merge operations for the node.

          • query_cache object

            Contains statistics about the query cache across all shards assigned to the node.

          • recovery object

            Contains statistics about recovery operations for the node.

          • refresh object

            Contains statistics about refresh operations for the node.

          • request_cache object

            Contains statistics about the request cache across all shards assigned to the node.

          • segments object

            Contains statistics about segments across all shards assigned to the node.

          • store object

            Contains statistics about the size of shards assigned to the node.

          • translog object

            Contains statistics about transaction log operations for the node.

          • warmer object

            Contains statistics about index warming operations for the node.

          • bulk object
          • shard_stats object
        • uuid string
        • health string

          Supported values include:

          • green (or GREEN): All shards are assigned.
          • yellow (or YELLOW): All primary shards are assigned, but one or more replica shards are unassigned. If a node in the cluster fails, some data could be unavailable until that node is repaired.
          • red (or RED): One or more primary shards are unassigned, so some data is unavailable. This can occur briefly during cluster startup as primary shards are assigned.
          • unknown
          • unavailable

          Values are green, GREEN, yellow, YELLOW, red, RED, unknown, or unavailable.

        • status string

          Values are open or close.

    • _shards object Required
      Hide _shards attributes Show _shards attributes object
      • 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.

      • failures array[object]
        Hide failures attributes Show failures attributes object
        • index string
        • node string
        • reason object Required

          Cause and details about a request failure. This class defines the properties common to all error types. Additional details are also provided, that depend on the error type.

        • shard number
        • status string
        • primary boolean
      • skipped number
    • _all object Required Additional properties
      Hide _all attributes Show _all attributes object
      • primaries object
        Hide primaries attributes Show primaries attributes object
        • completion object

          Contains statistics about completions across all shards assigned to the node.

        • docs object

          Contains statistics about documents across all primary shards assigned to the node.

        • fielddata object

          Contains statistics about the field data cache across all shards assigned to the node.

        • flush object

          Contains statistics about flush operations for the node.

        • get object

          Contains statistics about get operations for the node.

        • indexing object

          Contains statistics about indexing operations for the node.

        • indices object Additional properties

          Contains statistics about indices operations for the node.

        • merges object

          Contains statistics about merge operations for the node.

        • query_cache object

          Contains statistics about the query cache across all shards assigned to the node.

        • recovery object

          Contains statistics about recovery operations for the node.

        • refresh object

          Contains statistics about refresh operations for the node.

        • request_cache object

          Contains statistics about the request cache across all shards assigned to the node.

        • segments object

          Contains statistics about segments across all shards assigned to the node.

        • store object

          Contains statistics about the size of shards assigned to the node.

        • translog object

          Contains statistics about transaction log operations for the node.

        • warmer object

          Contains statistics about index warming operations for the node.

        • bulk object
        • shard_stats object
      • shards object
        Hide shards attribute Show shards attribute object
        • * array[object] Additional properties
          Hide * attributes Show * attributes object
          • commit
          • completion
          • docs
          • fielddata
          • flush
          • get
          • indexing
          • mappings
          • merges
          • shard_path
          • query_cache
          • recovery
          • refresh
          • request_cache
          • retention_leases
          • routing
          • search
          • segments
          • seq_no
          • store
          • translog
          • warmer
          • bulk
          • shards object Generally available; Added in 7.15.0
          • shard_stats
          • indices
      • total object
        Hide total attributes Show total attributes object
        • completion object

          Contains statistics about completions across all shards assigned to the node.

        • docs object

          Contains statistics about documents across all primary shards assigned to the node.

        • fielddata object

          Contains statistics about the field data cache across all shards assigned to the node.

        • flush object

          Contains statistics about flush operations for the node.

        • get object

          Contains statistics about get operations for the node.

        • indexing object

          Contains statistics about indexing operations for the node.

        • indices object Additional properties

          Contains statistics about indices operations for the node.

        • merges object

          Contains statistics about merge operations for the node.

        • query_cache object

          Contains statistics about the query cache across all shards assigned to the node.

        • recovery object

          Contains statistics about recovery operations for the node.

        • refresh object

          Contains statistics about refresh operations for the node.

        • request_cache object

          Contains statistics about the request cache across all shards assigned to the node.

        • segments object

          Contains statistics about segments across all shards assigned to the node.

        • store object

          Contains statistics about the size of shards assigned to the node.

        • translog object

          Contains statistics about transaction log operations for the node.

        • warmer object

          Contains statistics about index warming operations for the node.

        • bulk object
        • shard_stats object
      • uuid string
      • health string

        Supported values include:

        • green (or GREEN): All shards are assigned.
        • yellow (or YELLOW): All primary shards are assigned, but one or more replica shards are unassigned. If a node in the cluster fails, some data could be unavailable until that node is repaired.
        • red (or RED): One or more primary shards are unassigned, so some data is unavailable. This can occur briefly during cluster startup as primary shards are assigned.
        • unknown
        • unavailable

        Values are green, GREEN, yellow, YELLOW, red, RED, unknown, or unavailable.

      • status string

        Values are open or close.

GET /{index}/_stats/{metric}
GET _stats/fielddata?human&fields=my_join_field#question
resp = client.indices.stats(
    metric="fielddata",
    human=True,
    fields="my_join_field",
)
const response = await client.indices.stats({
  metric: "fielddata",
  human: "true",
  fields: "my_join_field",
});
response = client.indices.stats(
  metric: "fielddata",
  human: "true",
  fields: "my_join_field"
)
$resp = $client->indices()->stats([
    "metric" => "fielddata",
    "human" => "true",
    "fields" => "my_join_field",
]);
curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" "$ELASTICSEARCH_URL/_stats/fielddata?human&fields=my_join_field#question"
client.indices().stats(s -> s
    .fields("my_join_field")
    .metric("fielddata")
);