Skip to content

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 72 additions & 2 deletions output/openapi/elasticsearch-openapi.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 84 additions & 3 deletions output/schema/schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions output/typescript/types.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions specification/_json_spec/cluster.allocation_explain.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,22 @@
]
},
"params": {
"current_node": {
"type": "string",
"description": "Specifies the node ID or the name of the node to only explain a shard that is currently located on the specified node"
},
"index": {
"type": "IndexName",
"description": "Specifies the name of the index that you would like an explanation for"
},
"primary": {
"type": "boolean",
"description": "If true, returns explanation for the primary shard for the given shard ID"
},
"shard": {
"type": "integer",
"description": "Specifies the ID of the shard that you would like an explanation for"
},
"master_timeout": {
"type": "time",
"description": "Timeout for connection to master node"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 via the request body, or via query parameters, but not via both at the same time.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We try to avoid using the term "via"

Suggested change
* 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.
* 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.
Expand All @@ -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.
Copy link
Contributor

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?

Suggested change
* Specifies the node ID or the name of the node to only explain a shard that is currently located on the specified node.
* Explain a shard only if it is currently located on the specified node name or node ID.

*/
current_node?: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we prefer using aliases rather than primitive types when possible

Suggested change
current_node?: string
current_node?: NodeId

/**
* Specifies the name of the index that you would like an explanation for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Specifies the name of the index that you would like an explanation for.
* The name of the index that you would like an explanation for.

*/
index?: IndexName
/**
* If true, returns explanation for the primary shard for the given shard ID.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that the shard parameter is required when primary is specified? If so, we should mention that in the description.

Suggested change
* If true, returns explanation for the primary shard for the given shard ID.
* If true, returns an explanation for the primary shard for the specified shard ID.

*/
primary?: boolean
/**
* Specifies the ID of the shard that you would like an explanation for.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Specifies the ID of the shard that you would like an explanation for.
* An identifier for the shard that you would like an explanation for.

Alternatively, maybe "... that you want explained".

*/
shard?: integer
/**
* If true, returns information about disk usage and shard sizes.
* @server_default false
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# summary:
summary: All parameters in the request body
method_request: GET _cluster/allocation/explain
description: Run `GET _cluster/allocation/explain` to get an explanation for a shard's current allocation.
# type: request
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
summary: Query Parameters
method_request: GET _cluster/allocation/explain
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is incorrect, all the parameters need to be added to the method_request field for the automation to generate the examples correctly

Suggested change
method_request: GET _cluster/allocation/explain
method_request: GET _cluster/allocation/explain?index=my-index-000001&shard=0&primary=false&current_node=my-node

description: >
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
# type: request
value: |-
{}
alternatives:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can delete everything below the value field, as language examples are automatically generated

- 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&current_node="my-node"'
- language: Java
code: |
client.cluster().allocationExplain(a -> a
.currentNode("my-node")
.index("my-index-000001")
.primary(false)
.shard(0)
);
Loading