Skip to content

Commit 1a96cb9

Browse files
committed
[DOCS] Use s parameter in cat API overview example (#50616)
Updates a snippet to use the `s` query string parameter rather than piping the output to a separate `sort` command. This ensures the snippet is tested and available in clients other than curl (Kibana console, etc.). Issue was originally raised by @hackaholic in #40926.
1 parent 62b1d9c commit 1a96cb9

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

docs/reference/cat.asciidoc

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -102,19 +102,30 @@ order is important, you can change it.
102102

103103
Say you want to find the largest index in your cluster (storage used
104104
by all the shards, not number of documents). The `/_cat/indices` API
105-
is ideal. We only need to tweak two things. First, we want to turn
106-
off human mode. We'll use a byte-level resolution. Then we'll pipe
107-
our output into `sort` using the appropriate column, which in this
108-
case is the eighth one.
105+
is ideal. You only need to add three things to the API request:
109106

110-
[source,sh]
107+
. The `bytes` query string parameter with a value of `b` to get byte-level resolution.
108+
. The `s` (sort) parameter with a value of `store.size:desc` to sort the output
109+
by shard storage in descending order.
110+
. The `v` (verbose) parameter to include column headings in the response.
111+
112+
[source,console]
111113
--------------------------------------------------
112-
% curl '192.168.56.10:9200/_cat/indices?bytes=b' | sort -rnk8
113-
green wiki2 3 0 10000 0 105274918 105274918
114-
green wiki1 3 0 10000 413 103776272 103776272
115-
green foo 1 0 227 0 2065131 2065131
114+
GET /_cat/indices?bytes=b&s=store.size:desc&v
116115
--------------------------------------------------
117-
// NOTCONSOLE
116+
// TEST[setup:huge_twitter]
117+
// TEST[s/^/PUT twitter2\n{"settings": {"number_of_replicas": 0}}\n/]
118+
119+
The API returns the following response:
120+
121+
[source,txt]
122+
--------------------------------------------------
123+
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
124+
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 72171 72171
125+
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 1 0 0 0 230 230
126+
--------------------------------------------------
127+
// TESTRESPONSE[s/72171|230/\\d+/]
128+
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ non_json]
118129

119130
If you want to change the <<time-units,time units>>, use `time` parameter.
120131

0 commit comments

Comments
 (0)