How can the following query's results be sorted by index name?
curl "localhost:9200/_aliases?pretty"
How can the following query's results be sorted by index name?
curl "localhost:9200/_aliases?pretty"
You can ask ES to sort the results via the s
(sort) searchParameter using s=i
or s=index
curl "localhost:9200/_cat/indices?pretty&s=i"
curl "localhost:9200/_cat/aliases?pretty&s=index"
To see the column's headers, add "&v" :
curl "localhost:9200/_cat/indices?pretty&v&s=index"`.
You can find some explanations in the cat/indices documentation
GET _cat/aliases?v&s=index:desc&h=alias,index
Will give you:
alias index
app-logs-alias app-logs-2017-12-31
backend-logs-read backend-logs-2017-12-31
s = sort, v = various extra detail, h = headings to include,
I think that the best way to do this would be via the console. Something like this:
$ curl --silent 'http://path.to.cluster:9200/_cat/indices' | cut -d ' ' -f2 | sort
This is an old question, but now in 2020 the best way is :
with kibana :
GET _cat/indices/?pretty&s=store.size:desc
with curl :
http://localhost:9200/_cat/indices/?pretty&s=store.size:desc
Desc at the end for sort by desc
Just use this get request it will show all indexes with the column name.
http://localhost:9200/_cat/indices/?pretty&v
Additionally, not only by name you can sort it by any parameter you want with a get parameter of s=column_name
.
for example; to sort by the size you can do like:
http://localhost:9200/_cat/indices/?pretty&s=store.size
similarly for name:
http://localhost:9200/_cat/indices/?pretty&s=index
I don't think it exists by elasticsearch api.
Response from elasticsearch can be
{
"index1": {
"aliases": {}
}
}
Here is a pseudocode to get index from response
If aliasresponse is response from elasticsearch, then
indexlist=[]
for (key in aliasresponse) {
indexlist.add(key)
}
sort(indexlist)
For sorting, you can find libaries or custom methods.
Hope this helps.