OpenSearch/docs/reference/cat/indices.asciidoc
Nik Everett a4b3a95f5a Move flush in _cat/indices docs tests (#21117)
Moves the `_flush` in the `_cat/indices` snippets testing framework
to the very first test. We need to flush super early because index
size is cached for a few seconds so we really need to read a
consistent size on the first read so we can sort by it properly.

Closes #21062
2016-11-04 10:32:07 -04:00

124 lines
4.3 KiB
Plaintext

[[cat-indices]]
== cat indices
The `indices` command provides a cross-section of each index. This
information *spans nodes*. For example:
[source,js]
--------------------------------------------------
GET /_cat/indices/twi*?v&s=index
--------------------------------------------------
// CONSOLE
// TEST[setup:huge_twitter]
// TEST[s/^/POST _flush\n/]
// TEST[s/^/PUT twitter2\n{"settings": {"number_of_replicas": 0}}\n/]
// We flush very early here because the index's size is cached and we sort on
// size below. So to get a realistic sort on size we need to flush here or else
// the size is just whatever portion of the index is pushed out of memory
// during test setup which isn't deterministic.
Might respond with:
[source,txt]
--------------------------------------------------
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 5 0 0 0 260b 260b
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ _cat]
We can tell quickly how many shards make up an index, the number of
docs at the Lucene level, including hidden docs (e.g., from nested types),
deleted docs, primary store size, and total store size (all shards including replicas).
All these exposed metrics come directly from Lucene APIs.
[float]
[[pri-flag]]
=== Primaries
The index stats by default will show them for all of an index's
shards, including replicas. A `pri` flag can be supplied to enable
the view of relevant stats in the context of only the primaries.
[float]
[[examples]]
=== Examples
Which indices are yellow?
[source,js]
--------------------------------------------------
GET /_cat/indices?v&health=yellow
--------------------------------------------------
// CONSOLE
// TEST[continued]
Which looks like:
[source,txt]
--------------------------------------------------
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ/.+/ _cat]
What's my largest index by disk usage not including replicas?
[source,js]
--------------------------------------------------
GET /_cat/indices?v&s=store.size:desc
--------------------------------------------------
// CONSOLE
// TEST[continued]
Which looks like:
[source,txt]
--------------------------------------------------
health status index uuid pri rep docs.count docs.deleted store.size pri.store.size
yellow open twitter u8FNjxh8Rfy_awN11oDKYQ 1 1 1200 0 88.1kb 88.1kb
green open twitter2 nYFWZEO7TUiOjLQXBaYJpA 5 0 0 0 260b 260b
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
// TESTRESPONSE[s/u8FNjxh8Rfy_awN11oDKYQ|nYFWZEO7TUiOjLQXBaYJpA/.+/ _cat]
How many merge operations have the shards for the `twitter` completed?
[source,js]
--------------------------------------------------
GET /_cat/indices/twitter?pri&v&h=health,index,pri,rep,docs.count,mt
--------------------------------------------------
// CONSOLE
// TEST[continued]
Might look like:
[source,js]
--------------------------------------------------
health index pri rep docs.count mt pri.mt
yellow twitter 1 1 1200 16 16
--------------------------------------------------
// TESTRESPONSE[s/16/\\d+/ _cat]
How much memory is used per index?
[source,js]
--------------------------------------------------
GET /_cat/indices?v&h=i,tm&s=tm:desc
--------------------------------------------------
// CONSOLE
// TEST[continued]
Might look like:
[source,js]
--------------------------------------------------
i tm
twitter 8.1gb
twitter2 30.5kb
--------------------------------------------------
// TESTRESPONSE[s/\d+(\.\d+)?[tgmk]?b/\\d+(\\.\\d+)?[tgmk]?b/]
// TESTRESPONSE[_cat]