Browse Source

Console-ify curl statements for allocation explain API docs (#23190)

* Console-ify curl statements for allocation explain API docs

Relates to #23001

* Fix tests

* Remove exclusion from build.gradle

* Call out index creation in prose

* Add console back and skip test
Lee Hinman 8 years ago
parent
commit
5443f7d625
1 changed files with 24 additions and 8 deletions
  1. 24 8
      docs/reference/cluster/allocation-explain.asciidoc

+ 24 - 8
docs/reference/cluster/allocation-explain.asciidoc

@@ -13,16 +13,26 @@ when you might expect otherwise.
 [float]
 === Explain API Request
 
-To explain the allocation of a shard, issue a request:
+To explain the allocation of a shard, first an index should exist:
 
 [source,js]
 --------------------------------------------------
-$ curl -XGET 'http://localhost:9200/_cluster/allocation/explain' -d '{
+PUT /myindex
+--------------------------------------------------
+// TESTSETUP
+
+And then the allocation for shards of that index can be explained:
+
+[source,js]
+--------------------------------------------------
+GET /_cluster/allocation/explain
+{
   "index": "myindex",
   "shard": 0,
   "primary": true
-}'
+}
 --------------------------------------------------
+// CONSOLE
 
 Specify the `index` and `shard` id of the shard you would like an explanation
 for, as well as the `primary` flag to indicate whether to explain the primary
@@ -35,13 +45,16 @@ specified as either the node id or node name.
 
 [source,js]
 --------------------------------------------------
-$ curl -XGET 'http://localhost:9200/_cluster/allocation/explain' -d '{
+GET /_cluster/allocation/explain
+{
   "index": "myindex",
   "shard": 0,
   "primary": false,
   "current_node": "nodeA"                         <1>
-}'
+}
 --------------------------------------------------
+// CONSOLE
+// TEST[skip:no way of knowing the current_node]
 <1> The node where shard 0 currently has a replica on
 
 You can also have Elasticsearch explain the allocation of the first unassigned
@@ -49,8 +62,9 @@ shard that it finds by sending an empty body for the request:
 
 [source,js]
 --------------------------------------------------
-$ curl -XGET 'http://localhost:9200/_cluster/allocation/explain'
+GET /_cluster/allocation/explain
 --------------------------------------------------
+// CONSOLE
 
 [float]
 === Explain API Response
@@ -118,16 +132,18 @@ and shard sizes by setting the `include_disk_info` parameter to `true`:
 
 [source,js]
 --------------------------------------------------
-$ curl -XGET 'http://localhost:9200/_cluster/allocation/explain?include_disk_info=true'
+GET /_cluster/allocation/explain?include_disk_info=true
 --------------------------------------------------
+// CONSOLE
 
 Additionally, if you would like to include all decisions that were factored into the final
 decision, the `include_yes_decisions` parameter will return all decisions for each node:
 
 [source,js]
 --------------------------------------------------
-$ curl -XGET 'http://localhost:9200/_cluster/allocation/explain?include_yes_decisions=true'
+GET /_cluster/allocation/explain?include_yes_decisions=true
 --------------------------------------------------
+// CONSOLE
 
 The default value for `include_yes_decisions` is `false`, which will only
 include the `no` decisions in the response.  This is generally what you would