Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elasticsearch list indices sorted by name

How can the following query's results be sorted by index name?

curl "localhost:9200/_aliases?pretty" 
like image 654
10 cls Avatar asked Jul 25 '14 17:07

10 cls


People also ask

How do I list all indices in Elasticsearch?

You can query localhost:9200/_status and that will give you a list of indices and information about each.

How do I search index in Elasticsearch?

You can use the search API to search and aggregate data stored in Elasticsearch data streams or indices. The API's query request body parameter accepts queries written in Query DSL. The following request searches my-index-000001 using a match query. This query matches documents with a user.id value of kimchy .

How does elastic search sort work?

Elasticsearch comes with a good default out of the box. It sorts the results by relevance to the search query term, most relevant first. Elasticsearch measures the relevance score as a floating-point number called _score, and orders results in the descending order of their _score values.


2 Answers

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

like image 198
Romain Avatar answered Sep 21 '22 14:09

Romain


The best way for Elasticsearch 5x is like this:

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,

like image 25
Dennis Dyallo Avatar answered Sep 20 '22 14:09

Dennis Dyallo