我想列出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"
}
我想要一个所有索引的列表..
_stats命令提供了通过指定所需指标来自定义结果的方法。要获得索引,查询如下:
GET /_stats/indices
_stats查询的一般格式是:
/_stats
/_stats/{metric}
/_stats/{metric}/{indexMetric}
/{index}/_stats
/{index}/_stats/{metric}
指标在哪里:
indices, docs, store, indexing, search, get, merge,
refresh, flush, warmer, filter_cache, id_cache,
percolate, segments, fielddata, completion
作为对自己的练习,我写了一个小的elasticsearch插件,提供了列出elasticsearch索引的功能,而不需要任何其他信息。你可以在以下网址找到它:
http://blog.iterativ.ch/2014/04/11/listindices-writing-your-first-elasticsearch-java-plugin/
https://github.com/iterativ/elasticsearch-listindices
您还可以使用获取特定的索引
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