我想列出ElasticSearch服务器上的所有索引。我试了一下:

curl -XGET localhost:9200/

但它给了我这个:

{
  "ok" : true,
  "status" : 200,
  "name" : "El Aguila",
  "version" : {
    "number" : "0.19.3",
    "snapshot_build" : false
  },
  "tagline" : "You Know, for Search"
}

我想要一个所有索引的列表..


当前回答

列出索引+和列表一起显示其状态的最好方法之一是简单地执行下面的查询。

注意:最好使用Sense来获得正确的输出。

curl -XGET 'http://localhost:9200/_cat/shards'

示例输出如下所示。主要的优点是,它基本上显示了索引名称和它保存到的分片,索引大小和分片ip等

index1     0 p STARTED     173650  457.1mb 192.168.0.1 ip-192.168.0.1 
index1     0 r UNASSIGNED                                                 
index2     1 p STARTED     173435  456.6mb 192.168.0.1 ip-192.168.0.1 
index2     1 r UNASSIGNED                                                 
...
...
...

其他回答

使用kibana发送请求和获取响应,kibana可以自动完成弹性查询生成器,并且有更多的工具

看看kibana

 GET /_cat/indices

Kibana开发工具

http://localhost:5601/app/kibana#/dev_tools/console

通过Curl访问安全弹性搜索(更新2020)

如果弹性搜索是安全的,您可以使用此命令列出索引

curl http://username:password@localhost:9200/_aliases?pretty=true

我会给你一个可以在kibana上运行的查询。

GET /_cat/indices?v

而CURL版本将是

CURL -XGET http://localhost:9200/_cat/indices?v

Try

curl 'localhost:9200/_cat/indices?v'

它将以表格的方式为您提供以下自我说明的输出

health index    pri rep docs.count docs.deleted store.size pri.store.size
yellow customer   5   1          0            0       495b           495b

curl -XGET 'http://localhost:9200/_cluster/health?水平=指数'

这将输出如下所示

{
  "cluster_name": "XXXXXX:name",
  "status": "green",
  "timed_out": false,
  "number_of_nodes": 3,
  "number_of_data_nodes": 3,
  "active_primary_shards": 199,
  "active_shards": 398,
  "relocating_shards": 0,
  "initializing_shards": 0,
  "unassigned_shards": 0,
  "delayed_unassigned_shards": 0,
  "number_of_pending_tasks": 0,
  "number_of_in_flight_fetch": 0,
  "task_max_waiting_in_queue_millis": 0,
  "active_shards_percent_as_number": 100,
  "indices": {
    "logstash-2017.06.19": {
      "status": "green",
      "number_of_shards": 3,
      "number_of_replicas": 1,
      "active_primary_shards": 3,
      "active_shards": 6,
      "relocating_shards": 0,
      "initializing_shards": 0,
      "unassigned_shards": 0
    },
    "logstash-2017.06.18": {
      "status": "green",
      "number_of_shards": 3,
      "number_of_replicas": 1,
      "active_primary_shards": 3,
      "active_shards": 6,
      "relocating_shards": 0,
      "initializing_shards": 0,
      "unassigned_shards": 0
    }}