Link Search Menu Expand Document Documentation Menu

列表 API

2.18 版引入

列表 API 以分页格式检索有关索引和分片的统计信息。这简化了处理包含大量索引的响应的任务。

列表 API 支持两种操作

共享查询参数

所有列表 API 操作都支持以下可选查询参数。

参数 描述
v 通过向列添加标题来提供详细输出。它还添加了一些格式以帮助对齐每个列。本节中的所有示例都包含 v 参数。
help 列出给定操作的默认和其他可用标题。
h 将输出限制为特定标题。
format 返回结果的格式。有效值包括 jsonyamlcborsmile
s 按指定的列对输出进行排序。

示例

以下示例展示了如何使用可选查询参数来自定义所有列表 API 响应。

获取详细输出

要查询索引及其统计信息并获取包含响应中所有列标题的详细输出,请使用 v 查询参数,如下例所示。

请求

GET _list/indices?v

响应

health status index           uuid    pri rep  docs.count  docs.deleted
green  open   .kibana_1 - - - -              
yellow open    sample-index-1 - - - -
next_token null

获取所有可用标题

要查看所有可用标题,请使用 `help` 参数,语法如下:

GET _list/<operation_name>?help

请求

以下示例列表索引操作返回所有可用标题

GET _list/indices?help

响应

以下示例以表格形式显示索引及其健康状态

health     | h                              | current health status
status     | s                              | open/close status
index      | i,idx                          | index name
uuid       | id,uuid                        | index uuid
pri        | p,shards.primary,shardsPrimary | number of primary shards
rep        | r,shards.replica,shardsReplica | number of replica shards
docs.count | dc,docsCount                   | available docs

获取部分标题

要将输出限制为部分标题,请使用 `h` 参数,语法如下:

GET _list/<operation_name>?h=<header_name_1>,<header_name_2>&v

对于任何操作,您可以使用 `help` 参数确定哪些标题可用,然后使用 `h` 参数将输出限制为仅包含部分标题。

请求

以下示例将响应中的索引限制为仅包含索引名称和健康状态标题。

GET _list/indices?h=health,index

响应

green  .kibana_1
yellow sample-index-1
next_token null

按标题排序

要按标题对单页输出进行排序,请使用 `s` 参数,语法如下:

GET _list/<operation_name>?s=<header_name_1>,<header_name_2>

请求

以下示例请求按索引名称对索引进行排序

GET _list/indices?s=h,i

响应

green sample-index-2
yellow sample-index-1
next_token null

以 JSON 格式检索数据

默认情况下,列表 API 以 text/plain 格式返回数据。其他支持的格式包括 YAMLCBORSmile

要以 JSON 格式检索数据,请使用 format=json 参数,语法如下。

如果您使用安全插件,请确保您拥有适当的权限。

请求

GET _list/<operation_name>?format=json

请求

GET _list/indices?format=json

响应

响应包含 JSON 格式的数据

{
  "next_token": null,
  "indices": [
    {
      "health": "green",
      "status": "-",
      "index": ".kibana_1",
      "uuid": "-",
      "pri": "-",
      "rep": "-",
      "docs.count": "-",
      "docs.deleted": "-",
      "store.size": "-",
      "pri.store.size": "-"
    },
    {
      "health": "yellow",
      "status": "-",
      "index": "sample-index-1",
      "uuid": "-",
      "pri": "-",
      "rep": "-",
      "docs.count": "-",
      "docs.deleted": "-",
      "store.size": "-",
      "pri.store.size": "-"
    }
  ]
}

相关文章

剩余 350 字符

有问题?

想贡献?