English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Generally, the results from various Elasticsearch APIs are displayed in JSON format. However, JSON is not always easy to read. Therefore, Elasticsearch provides the cat APIs feature, which helps to make the printed format of the results more readable and understandable. Various parameters are used in the cat API, which have different purposes, such as-The term V makes the output verbose.
Let's understand the cat API in more detail in this chapter.
Detailed output can well display the result of the cat command. In the example given below, we obtained the detailed information of various indices existing in the cluster.
GET /_cat/indices?v
After running the above code, we get the following response:
health status index uuid pri repdocs.countdocs.deletedstore.sizepri.store.size yellow open schools RkMyEn2SQ4yUgzT6EQYuAA 1 1 2 1 21.6kb 21.6kb yellow open index_4_analysis zVmZdM1sTV61YJYrNXf1gg 1 1 0 0 283b 283b yellow open sensor-2018-01-01 KIrrHwABRB-ilGqTu3OaVQ 1 1 1 0 4.2kb 4.2kb yellow open colleges 3ExJbdl2R1qDLssIkwDAug 1 1 0 0 283b 283b
The h parameter (also known as header) is only used to display the columns mentioned in the command.
GET /_cat/nodes?h=ip,port
After running the above code, we get the following response:
127.0.0.1 9300
The sort command accepts a query string, which can sort the table by the specified column in the query. The default sort is ascending, but it can be changed by adding :desc to the column.
The following example shows the result of the template sorted in descending order by field index patterns.
GET _cat/templates?v&s=order:desc,index_patterns
After running the above code, we get the following response:
name index_patterns order version .triggered_watches [.triggered_watches]*] 2147483647 .watch-history-9 [.watcher-history-9*] 2147483647 .watches [.watches*] 2147483647 .kibana_task_manager [.kibana_task_manager] 0 7000099
The 'count' parameter provides the count of documents in the entire cluster.
GET /_cat/count?v
After running the above code, we get the following response:
epoch timestamp count 1557633536 03:58:56 17809