我想列出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"
}

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


当前回答

您还可以使用获取特定的索引

curl -X GET "localhost:9200/<INDEX_NAME>"
e.g.   curl -X GET "localhost:9200/twitter"
You may get output like:
{
  "twitter": {
     "aliases": { 

     },
     "mappings": { 

     },
     "settings": {
     "index": {
        "creation_date": "1540797250479",
        "number_of_shards": "3",
        "number_of_replicas": "2",
        "uuid": "CHYecky8Q-ijsoJbpXP95w",
        "version": {
            "created": "6040299"
        },
       "provided_name": "twitter"
      }
    }
  }
}

更多信息

https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-get-index.html

其他回答

我会给你一个可以在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

对于Elasticsearch 6。X,我发现下面的方法最有帮助。每个响应提供不同的数据。

# more verbose
curl -sS 'localhost:9200/_stats' | jq -C ".indices" | less

# less verbose, summary
curl -sS 'localhost:9200/_cluster/health?level=indices' | jq -C ".indices" | less

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

看看kibana

 GET /_cat/indices

Kibana开发工具

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

下面是查看db中索引的另一种方法:

curl -sG somehost-dev.example.com:9200/_status --user "credentials:password" | sed 's/,/\n/g' | grep index | grep -v "size_in" | uniq


{ "index":"tmpdb"}

{ "index":"devapp"}