-
Notifications
You must be signed in to change notification settings - Fork 108
Add Cluster/Allocation/Explain Query Param Example #4849
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6eab9dd
695ac41
98bba07
c1a4840
c370c5d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -25,6 +25,7 @@ import { Duration } from '@_types/Time' | |||||
/** | ||||||
* Explain the shard allocations. | ||||||
* Get explanations for shard allocations in the cluster. | ||||||
* This API accepts the current_node, index, primary and shard parameters in the request body or in query parameters, but not in both at the same time. | ||||||
* For unassigned shards, it provides an explanation for why the shard is unassigned. | ||||||
* 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. | ||||||
* 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. | ||||||
|
@@ -44,6 +45,22 @@ export interface Request extends RequestBase { | |||||
} | ||||||
] | ||||||
query_parameters: { | ||||||
/** | ||||||
* Specifies the node ID or the name of the node to only explain a shard that is currently located on the specified node. | ||||||
*/ | ||||||
current_node?: string | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we prefer using aliases rather than primitive types when possible
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Happy to change! I had copied the parameter definitions from later in the file, so will change there as well. Can I ask what the benefit of this is? And does this apply to other primitives, like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. benefit is that some clients (like .net) use these aliases to provide shortcuts/helpers or for documentation purposes, it applies to most strings, most "time" related numbers, versions numbers and others ( |
||||||
/** | ||||||
* Specifies the name of the index that you would like an explanation for. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, happy to change but will change below as well. Side question, in this case the same parameters are defined as both |
||||||
*/ | ||||||
index?: IndexName | ||||||
/** | ||||||
* If true, returns explanation for the primary shard for the given shard ID. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean that the
Suggested change
|
||||||
*/ | ||||||
primary?: boolean | ||||||
/** | ||||||
* Specifies the ID of the shard that you would like an explanation for. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Alternatively, maybe "... that you want explained". |
||||||
*/ | ||||||
shard?: integer | ||||||
/** | ||||||
* If true, returns information about disk usage and shard sizes. | ||||||
* @server_default false | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
summary: Query Parameters | ||
method_request: GET _cluster/allocation/explain?index=my-index-000001&shard=0&primary=false¤t_node=my-node | ||
description: > | ||
Run `GET _cluster/allocation/explain?index="my-index-000001"&shard=0&primary=false¤t_node="my-node` to get an explanation for a shard's current allocation. No parameters are required in the request body | ||
# type: request | ||
value: |- | ||
{} | ||
alternatives: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can delete everything below the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did not know that! Thank you, that's very clever |
||
- language: Python | ||
code: |- | ||
resp = client.cluster.allocation_explain( | ||
index="my-index-000001", | ||
shard=0, | ||
primary=False, | ||
current_node="my-node", | ||
) | ||
- language: JavaScript | ||
code: |- | ||
const response = await client.cluster.allocationExplain({ | ||
index: "my-index-000001", | ||
shard: 0, | ||
primary: false, | ||
current_node: "my-node", | ||
}); | ||
- language: Ruby | ||
code: |- | ||
response = client.cluster.allocation_explain( | ||
index: "my-index-000001", | ||
shard: 0, | ||
primary: false, | ||
current_node: "my-node", | ||
body: {} | ||
) | ||
- language: PHP | ||
code: |- | ||
$resp = $client->cluster()->allocationExplain([ | ||
"index" => "my-index-000001", | ||
"shard" => 0, | ||
"primary" => false, | ||
"current_node" => "my-node", | ||
"body" => [], | ||
]); | ||
- language: curl | ||
code: 'curl -X GET -H "Authorization: ApiKey $ELASTIC_API_KEY" | ||
"$ELASTICSEARCH_URL/_cluster/allocation/explain?index="my-index-000001"&shard=0&primary=false¤t_node="my-node"' | ||
- language: Java | ||
code: | | ||
client.cluster().allocationExplain(a -> a | ||
.currentNode("my-node") | ||
.index("my-index-000001") | ||
.primary(false) | ||
.shard(0) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what is meant?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the description verbatim from the existing API docs, see the definition for the
current_node
parameter. I don't like the existing wording myself but figured it had already passed through a review to have been published. Happy to change if you agree