以下查询的结果如何按索引名称排序?
curl "localhost:9200/_aliases?pretty"
您可以要求 ES 使用
s
或 s=i
通过
s=index
(排序)searchParameter 对结果进行排序
curl "localhost:9200/_cat/indices?pretty&s=i"
curl "localhost:9200/_cat/aliases?pretty&s=index"
要查看列标题,请添加
&v
:
curl "localhost:9200/_cat/indices?pretty&v&s=index"`.
GET _cat/aliases?v&s=index:desc&h=alias,index
会给你:
alias index
app-logs-alias app-logs-2017-12-31
backend-logs-read backend-logs-2017-12-31
s = 排序,v = 各种额外细节,h = 要包含的标题,
我认为最好的方法是通过控制台。像这样的东西:
$ curl --silent 'http://path.to.cluster:9200/_cat/indices' | cut -d ' ' -f2 | sort
这是一个老问题,但现在2020年最好的方法是:
与 kibana :
GET _cat/indices/?pretty&s=store.size:desc
有卷曲:
http://localhost:9200/_cat/indices/?pretty&s=store.size:desc
末尾有 DES 按 desc 排序
只需使用此 get 请求,它将显示带有列名称的所有索引。
http://localhost:9200/_cat/indices/?pretty&v
此外,不仅可以按名称排序,您还可以通过任何您想要的参数对其进行排序,获取参数为
s=column_name
。
例如;按大小排序,您可以这样做:
http://localhost:9200/_cat/indices/?pretty&s=store.size
名称也类似:
http://localhost:9200/_cat/indices/?pretty&s=index
我认为elasticsearch api不存在它。
来自elasticsearch的响应可以是
{
"index1": {
"aliases": {}
}
}
这是从响应中获取索引的伪代码
如果aliasresponse是来自elasticsearch的响应,那么
indexlist=[]
for (key in aliasresponse) {
indexlist.add(key)
}
sort(indexlist)
为了排序,您可以找到库或自定义方法。
希望这有帮助。