From 06049283a05e6f75fdf3ad26e18f8ad6e90ea302 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Fri, 7 Oct 2016 16:28:49 -0400 Subject: [PATCH] CONSOLEify some _cat docs `/_cat/count`, `/_cat/fielddata`, and `/_cat/health`. Three more files down, 141 to go. Relates to #18160 --- docs/build.gradle | 3 - docs/reference/cat/count.asciidoc | 41 +++++++--- docs/reference/cat/fielddata.asciidoc | 107 ++++++++++++++++++++------ docs/reference/cat/health.asciidoc | 40 ++++++++-- 4 files changed, 146 insertions(+), 45 deletions(-) diff --git a/docs/build.gradle b/docs/build.gradle index ca852d1e61e..83fea920d2b 100644 --- a/docs/build.gradle +++ b/docs/build.gradle @@ -93,9 +93,6 @@ buildRestTests.expectedUnconvertedCandidates = [ 'reference/analysis/tokenfilters/stop-tokenfilter.asciidoc', 'reference/analysis/tokenfilters/synonym-tokenfilter.asciidoc', 'reference/analysis/tokenfilters/word-delimiter-tokenfilter.asciidoc', - 'reference/cat/count.asciidoc', - 'reference/cat/fielddata.asciidoc', - 'reference/cat/health.asciidoc', 'reference/cat/indices.asciidoc', 'reference/cat/master.asciidoc', 'reference/cat/nodeattrs.asciidoc', diff --git a/docs/reference/cat/count.asciidoc b/docs/reference/cat/count.asciidoc index ff64f2bc73b..9a8c1b8c65b 100644 --- a/docs/reference/cat/count.asciidoc +++ b/docs/reference/cat/count.asciidoc @@ -4,17 +4,38 @@ `count` provides quick access to the document count of the entire cluster, or individual indices. -[source,sh] +[source,js] -------------------------------------------------- -% curl 192.168.56.10:9200/_cat/indices -green wiki1 3 0 10000 331 168.5mb 168.5mb -green wiki2 3 0 428 0 8mb 8mb - -% curl 192.168.56.10:9200/_cat/count -1384314124582 19:42:04 10428 - -% curl 192.168.56.10:9200/_cat/count/wiki2 -1384314139815 19:42:19 428 +GET /_cat/count?v -------------------------------------------------- +// CONSOLE +// TEST[setup:big_twitter] +// TEST[s/^/POST test\/test\?refresh\n{"test": "test"}\n/] + +Looks like: + +[source,js] +-------------------------------------------------- +epoch timestamp count +1475868259 15:24:19 121 +-------------------------------------------------- +// TESTRESPONSE[s/1475868259 15:24:19/\\d+ \\d+:\\d+:\\d+/ _cat] + +Or for a single index: + +[source,js] +-------------------------------------------------- +GET /_cat/count/twitter?v +-------------------------------------------------- +// CONSOLE +// TEST[continued] + +[source,js] +-------------------------------------------------- +epoch timestamp count +1475868259 15:24:20 120 +-------------------------------------------------- +// TESTRESPONSE[s/1475868259 15:24:20/\\d+ \\d+:\\d+:\\d+/ _cat] + NOTE: The document count indicates the number of live documents and does not include deleted documents which have not yet been cleaned up by the merge process. diff --git a/docs/reference/cat/fielddata.asciidoc b/docs/reference/cat/fielddata.asciidoc index 86b14c65f80..c4dc10fbff1 100644 --- a/docs/reference/cat/fielddata.asciidoc +++ b/docs/reference/cat/fielddata.asciidoc @@ -1,39 +1,98 @@ [[cat-fielddata]] == cat fielddata -`fielddata` shows how much heap memory is currently being used by fielddata +`fielddata` shows how much heap memory is currently being used by fielddata on every data node in the cluster. -[source,sh] + +//// +Hidden setup snippet to build an index with fielddata so our results are real: +[source,js] -------------------------------------------------- -% curl '192.168.56.10:9200/_cat/fielddata?v' -id host ip node field size -bGG90GEiSGeezlbrcugAYQ myhost1 10.20.100.200 bGG90GE body 159.8kb -bGG90GEiSGeezlbrcugAYQ myhost1 10.20.100.200 bGG90GE text 225.7kb -H5dfFeANQaCL6xC8VxjAwg myhost2 10.20.100.201 H5dfFeA body 159.8kb -H5dfFeANQaCL6xC8VxjAwg myhost2 10.20.100.201 H5dfFeA text 275.3kb -I8hydUG3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 I8hydUG body 109.2kb -I8hydUG3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 I8hydUG text 175.3kb +PUT test +{ + "mappings": { + "test": { + "properties": { + "body": { + "type": "text", + "fielddata":true + }, + "soul": { + "type": "text", + "fielddata":true + } + } + } + } +} +POST test/test?refresh +{ + "body": "some words so there is a little field data", + "soul": "some more words" +} + +# Perform a search to load the field data +POST test/_search?sort=body,soul -------------------------------------------------- +// CONSOLE +//// + +[source,js] +-------------------------------------------------- +GET /_cat/fielddata?v +-------------------------------------------------- +// CONSOLE +// TEST[continued] + +Looks like: + +[source,js] +-------------------------------------------------- +id host ip node field size +Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in body 544b +Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in soul 480b +-------------------------------------------------- +// TESTRESPONSE[s/544b|480b/\\d+(\\.\\d+)?[tgmk]?b/] +// TESTRESPONSE[s/Nqk-6in[^ ]*/.+/ s/soul|body/\\w+/ _cat] Fields can be specified either as a query parameter, or in the URL path: -[source,sh] +[source,js] -------------------------------------------------- -% curl '192.168.56.10:9200/_cat/fielddata?v&fields=body' -id host ip node field size -bGG90GEiSGeezlbrcugAYQ myhost1 10.20.100.200 bGG90GE body 159.8kb -H5dfFeANQaCL6xC8VxjAwg myhost2 10.20.100.201 H5dfFeA body 159.8kb -I8hydUG3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 I8hydUG body 109.2kb +GET /_cat/fielddata?v&fields=body +-------------------------------------------------- +// CONSOLE +// TEST[continued] -% curl '192.168.56.10:9200/_cat/fielddata/body,text?v' -id host ip node field size -bGG90GEiSGeezlbrcugAYQ myhost1 10.20.100.200 bGG90GE body 159.8kb -bGG90GEiSGeezlbrcugAYQ myhost1 10.20.100.200 bGG90GE text 225.7kb -H5dfFeANQaCL6xC8VxjAwg myhost2 10.20.100.201 H5dfFeA body 159.8kb -H5dfFeANQaCL6xC8VxjAwg myhost2 10.20.100.201 H5dfFeA text 275.3kb -I8hydUG3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 I8hydUG body 109.2kb -I8hydUG3R0q1AJ-HUEvkSQ myhost3 10.20.100.202 I8hydUG text 175.3kb +Which looks like: + +[source,js] -------------------------------------------------- +id host ip node field size +Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in body 544b +-------------------------------------------------- +// TESTRESPONSE[s/544b|480b/\\d+(\\.\\d+)?[tgmk]?b/] +// TESTRESPONSE[s/Nqk-6in[^ ]*/.+/ _cat] + +And it accepts a comma delimited list: + +[source,js] +-------------------------------------------------- +GET /_cat/fielddata/body,soul?v +-------------------------------------------------- +// CONSOLE +// TEST[continued] + +Which produces the same output as the first snippet: + +[source,js] +-------------------------------------------------- +id host ip node field size +Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in body 544b +Nqk-6inXQq-OxUfOUI8jNQ 127.0.0.1 127.0.0.1 Nqk-6in soul 480b +-------------------------------------------------- +// TESTRESPONSE[s/544b|480b/\\d+(\\.\\d+)?[tgmk]?b/] +// TESTRESPONSE[s/Nqk-6in[^ ]*/.+/ s/soul|body/\\w+/ _cat] The output shows the individual fielddata for the`body` and `text` fields, one row per field per node. diff --git a/docs/reference/cat/health.asciidoc b/docs/reference/cat/health.asciidoc index bf9b3f17443..53afa7700b9 100644 --- a/docs/reference/cat/health.asciidoc +++ b/docs/reference/cat/health.asciidoc @@ -2,17 +2,39 @@ == cat health `health` is a terse, one-line representation of the same information -from `/_cluster/health`. It has one option `ts` to disable the -timestamping. +from `/_cluster/health`. -[source,sh] +[source,js] -------------------------------------------------- -% curl localhost:9200/_cat/health -1384308967 18:16:07 foo green 3 3 3 3 0 0 0 -% curl 'localhost:9200/_cat/health?v&ts=0' -cluster status nodeTotal nodeData shards pri relo init unassign tasks -foo green 3 3 3 3 0 0 0 0 +GET /_cat/health?v -------------------------------------------------- +// CONSOLE +// TEST[s/^/PUT twitter\n{"settings":{"number_of_replicas": 0}}\n/] + +[source,js] +-------------------------------------------------- +epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent +1475871424 16:17:04 docs_integTest green 1 1 5 5 0 0 0 0 - 100.0% +-------------------------------------------------- +// TESTRESPONSE[s/1475871424 16:17:04/\\d+ \\d+:\\d+:\\d+/ s/elasticsearch/[^ ]+/ _cat] + +It has one option `ts` to disable the timestamping: + +[source,js] +-------------------------------------------------- +GET /_cat/health?v&ts=0 +-------------------------------------------------- +// CONSOLE +// TEST[s/^/PUT twitter\n{"settings":{"number_of_replicas": 0}}\n/] + +which looks like: + +[source,js] +-------------------------------------------------- +cluster status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent +elasticsearch green 1 1 5 5 0 0 0 0 - 100.0% +-------------------------------------------------- +// TESTRESPONSE[s/elasticsearch/[^ ]+/ _cat] A common use of this command is to verify the health is consistent across nodes: @@ -27,6 +49,7 @@ across nodes: [3] 20:20:52 [SUCCESS] es2.vm 1384309218 18:20:18 foo green 3 3 3 3 0 0 0 0 -------------------------------------------------- +// NOTCONSOLE A less obvious use is to track recovery of a large cluster over time. With enough shards, starting a cluster, or even recovering after @@ -42,6 +65,7 @@ to track its progress is by using this command in a delayed loop: 1384309806 18:30:06 foo green 3 3 1832 916 4 0 0 ^C -------------------------------------------------- +// NOTCONSOLE In this scenario, we can tell that recovery took roughly four minutes. If this were going on for hours, we would be able to watch the