Sorting 按名称排序的Elasticsearch列表索引
以下查询的结果如何按索引名排序Sorting 按名称排序的Elasticsearch列表索引,sorting,elasticsearch,aliases,Sorting,elasticsearch,Aliases,以下查询的结果如何按索引名排序 curl "localhost:9200/_aliases?pretty" 我认为ElasticSearchAPI不存在它 elasticsearch的响应可以是 { "index1": { "aliases": {} } } 下面是从响应中获取索引的伪代码 如果aliasresponse是elasticsearch的响应,则 indexlist=[] for (key in aliasresponse) { indexlist
curl "localhost:9200/_aliases?pretty"
我认为ElasticSearchAPI不存在它 elasticsearch的响应可以是
{
"index1": {
"aliases": {}
}
}
下面是从响应中获取索引的伪代码
如果aliasresponse是elasticsearch的响应,则
indexlist=[]
for (key in aliasresponse) {
indexlist.add(key)
}
sort(indexlist)
对于排序,您可以找到库或自定义方法
希望这有帮助 我认为最好的方法是通过控制台。大概是这样的:
$curl——静默'http://path.to.cluster:9200/_cat/indices“|切割-d”—f2 |排序
您可以要求ES使用s=i
或s=index
通过s
(排序)搜索参数对结果进行排序
curl "localhost:9200/_cat/indices?pretty&s=i"
curl "localhost:9200/_cat/aliases?pretty&s=index"
要查看列标题,请添加“&v”:
您可以在中找到一些解释Elasticsearch 5x的最佳方式如下:
将为您提供:
alias index
app-logs-alias app-logs-2017-12-31
backend-logs-read backend-logs-2017-12-31
s=排序,v=各种额外细节,h=要包含的标题
只需使用这个get请求,它就会用列名显示所有索引
http://localhost:9200/_cat/indices/?pretty&v
此外,不仅可以按名称,还可以使用get参数s=column\u name
按任何参数对其进行排序
比如,;要按大小排序,可以执行以下操作:
http://localhost:9200/_cat/indices/?pretty&s=store.size
名称类似:
http://localhost:9200/_cat/indices/?pretty&s=index
这是一个老问题,但现在到2020年,最好的办法是: 与kibana:
GET _cat/indices/?pretty&s=store.size:desc
带卷曲:
http://localhost:9200/_cat/indices/?pretty&s=store.size:desc
按Desc排序的末尾Desc您不能自己排序吗?我认为它不存在。@ErBnAcharya结果没有字段名可指定。@ErBnAcharya这是怎么做到的?您是否尝试过
curl localhost:9200/_cat/aliases | sort
?我知道这是一种完全不同的格式,但它可能是您真正想要的格式,我建议使用@Alcanzar所说的sort
。试试curl localhost:9200/_cat/index | sort-nk2Ah,我想看看是否有api替代方案。除了像copy myindex testindex(closed?)这样简单的重新索引外,似乎还有一些意想不到的遗漏。啊,很好。我将它稍微更改为:curl--silent'http://path.to.cluster:9200/_cat/aliases“|cut-d”“-f1 | sort
我不得不将剪切更改为使用-f3
而不是-f2
。您可以使用-n(数字排序)
选项和-k(键)
选项进行排序,而不是使用剪切
。例如,curl'localhost:9200/_cat/index'| sort-nk3
你是什么意思?curl只是在做一个http请求,你可以在浏览器中使用它,也可以在任何语言的http客户机上使用它。我无法通过一个邮递员get在ES 5.2+上实现这些功能。我得到400个响应“非法参数\u异常,请求[/\u别名/]包含无法识别的参数:[s]”您还可以更改排序顺序:/\u cat/index?v&s=docs.count:desc
加上+1举手进行反向排序此答案以非常简洁的方式讲述了这么多功能。
GET _cat/indices/?pretty&s=store.size:desc
http://localhost:9200/_cat/indices/?pretty&s=store.size:desc