Skip to content

Commit 6eab9dd

Browse files
Add Cluster/Allocation/Explain Query Param Example
Extends the documentation for the `cluster/allocation/explain` API after query parameter support was added in #129342. A second example request was provided with all four query parameters and an empty request body.
1 parent 3898339 commit 6eab9dd

File tree

4 files changed

+72
-1
lines changed

4 files changed

+72
-1
lines changed

specification/_json_spec/cluster.allocation_explain.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@
1919
]
2020
},
2121
"params": {
22+
"current_node": {
23+
"type": "string",
24+
"description": "Specifies the node ID or the name of the node to only explain a shard that is currently located on the specified node"
25+
},
26+
"index": {
27+
"type": "IndexName",
28+
"description": "Specifies the name of the index that you would like an explanation for"
29+
},
30+
"primary": {
31+
"type": "boolean",
32+
"description": "If true, returns explanation for the primary shard for the given shard ID"
33+
},
34+
"shard": {
35+
"type": "integer",
36+
"description": "Specifies the ID of the shard that you would like an explanation for"
37+
},
2238
"master_timeout": {
2339
"type": "time",
2440
"description": "Timeout for connection to master node"

specification/cluster/allocation_explain/ClusterAllocationExplainRequest.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { Duration } from '@_types/Time'
2525
/**
2626
* Explain the shard allocations.
2727
* Get explanations for shard allocations in the cluster.
28+
* This API accepts the current_node, index, primary and shard parameters via the request body, or via query parameters, but not via both at the same time.
2829
* For unassigned shards, it provides an explanation for why the shard is unassigned.
2930
* For assigned shards, it provides an explanation for why the shard is remaining on its current node and has not moved or rebalanced to another node.
3031
* This API can be very useful when attempting to diagnose why a shard is unassigned or why a shard continues to remain on its current node when you might expect otherwise.

specification/cluster/allocation_explain/examples/request/ClusterAllocationExplainRequestExample1.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# summary:
1+
summary: All parameters in the request body
22
method_request: GET _cluster/allocation/explain
33
description: Run `GET _cluster/allocation/explain` to get an explanation for a shard's current allocation.
44
# type: request
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
summary: Query Parameters
2+
method_request: GET _cluster/allocation/explain
3+
description: >
4+
Run `GET _cluster/allocation/explain?index="my-index-000001"&shard=0&primary=false&current_node="my-node` to get an explanation for a shard's current allocation. No parameters are required in the request body
5+
# type: request
6+
value: |-
7+
{}
8+
alternatives:
9+
- language: Python
10+
code: |-
11+
resp = client.cluster.allocation_explain(
12+
index="my-index-000001",
13+
shard=0,
14+
primary=False,
15+
current_node="my-node",
16+
)
17+
- language: JavaScript
18+
code: |-
19+
const response = await client.cluster.allocationExplain({
20+
index: "my-index-000001",
21+
shard: 0,
22+
primary: false,
23+
current_node: "my-node",
24+
});
25+
- language: Ruby
26+
code: |-
27+
response = client.cluster.allocation_explain(
28+
index: "my-index-000001",
29+
shard: 0,
30+
primary: false,
31+
current_node: "my-node",
32+
body: {}
33+
)
34+
- language: PHP
35+
code: |-
36+
$resp = $client->cluster()->allocationExplain([
37+
"index" => "my-index-000001",
38+
"shard" => 0,
39+
"primary" => false,
40+
"current_node" => "my-node",
41+
"body" => [],
42+
]);
43+
- language: curl
44+
code:
45+
'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY"
46+
"$ELASTICSEARCH_URL/_cluster/allocation/explain?index="my-index-000001"&shard=0&primary=false&current_node="my-node"'
47+
- language: Java
48+
code: |
49+
client.cluster().allocationExplain(a -> a
50+
.currentNode("my-node")
51+
.index("my-index-000001")
52+
.primary(false)
53+
.shard(0)
54+
);

0 commit comments

Comments
 (0)