Search...Cluster(3pm)
π Search::Elasticsearch::Client::8_0::Direct::Cluster β the cluster-level client, bestie π
okay so this page lives in your friendly neighbourhood User Contributed Perl Documentation, and the module it's hyping up is Search::Elasticsearch::Client::8_0::Direct::Cluster. yes the name is long. no we are not shortening it. it's iconic like that. π
β¨ VERSION β¨
version 8.12 π
πΈ DESCRIPTION πΈ
okay so this module is your girl for making cluster-level requests. we're talking:
- getting and setting cluster-level settings
- manually rerouting shards
- retrieving stuff for monitoring purposes
and it does Search::Elasticsearch::Role::Client::Direct, so you know it's got the whole direct-client thing going on. β¨
π METHODS π
π©Ί health()
$response = $e->cluster->health(
index => 'index' | \@indices # optional
);
the health() method pulls info about cluster health, and it hands you back "red", "yellow" or "green" to tell you how the cluster, the indices, or the shards are doing. vibe check, but for your cluster. π
Query string parameters:
"error_trace""human""level""local""master_timeout""timeout""wait_for_active_shards""wait_for_events""wait_for_no_initializing_shards""wait_for_no_relocating_shards""wait_for_nodes""wait_for_status"
See the cluster health docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-health.html> for more information.
π stats()
$response = $e->cluster->stats(
node_id => 'node' | \@nodes # optional
);
returns high-level cluster stats, and if you want, you can limit them to just the nodes you list. lowkey handy. π
Query string parameters:
"error_trace""flat_settings""human""timeout"
See the cluster stats docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-stats.html> for more information.
π get_settings()
$response = $e->cluster->get_settings()
the get_settings() method retrieves the cluster-wide settings that somebody set with the "put_settings()" method. it's giving "who did this and what did they set". π
Query string parameters:
"error_trace""flat_settings""human""include_defaults""master_timeout""timeout"
See the cluster settings docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html> for more information.
βοΈ put_settings()
$response = $e->cluster->put_settings( %settings );
the put_settings() method sets cluster-wide settings. you can do it either:
- transiently β these do not survive restarts
- permanently β these do survive restarts
For instance:
$response = $e->cluster->put_settings(
body => {
transient => { "discovery.zen.minimum_master_nodes" => 6 }
}
);
Query string parameters:
"error_trace""flat_settings""human"
See the cluster settings docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-update-settings.html> for more information.
πΊοΈ state()
$response = $e->cluster->state(
metric => $metric | \@metrics # optional
index => $index | \@indices # optional
);
the state() method returns the current cluster state β from the master node, or from the responding node if "local" is set to "true". main character energy either way. π
by default it returns all the metrics, but you can limit it to any of:
"_all""blocks""metadata""nodes""routing_table"
and metrics for indices can be limited to particular indices with the "index" parameter. π
Query string parameters:
"allow_no_indices""error_trace""expand_wildcards""flat_settings""human""ignore_unavailable""local""master_timeout""wait_for_metadata_version""wait_for_timeout"
See the cluster state docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-state.html> for more information.
π§© allocation_explain()
$response = $e->cluster->allocation_explain(
body => { ... shard selectors ...} # optional
);
returns info about why a shard is allocated, or unallocated, or why. yes, that's how the original says it, and we are respecting it fr fr. π
Query string parameters:
"error_trace""human""include_disk_info""include_yes_decisions"
See the cluster allocation explain docs <https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-allocation-explain.html> for more information.
β³ pending_tasks()
$response = $e->cluster->pending_tasks();
returns a list of cluster-level tasks that are still pending on the master node. we love a queue that refuses to move. π
Query string parameters:
"error_trace""human""local""master_timeout"
See the pending tasks docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-pending.html> for more information.
π reroute()
$e->cluster->reroute(
body => { commands }
);
the reroute() method is how you manually reallocate shards from one node to another. the "body" should contain the "commands" telling it which changes to make. For instance:
$e->cluster->reroute(
body => {
commands => [
{ move => {
index => 'test',
shard => 0,
from_node => 'node_1',
to_node => 'node_2
}},
{ allocate => {
index => 'test',
shard => 1,
node => 'node_3'
}}
]
}
);
β οΈ bestie, peep that to_node => 'node_2 line up there β that's exactly how it appears in the original, unterminated quote and all. we copy it character for character, no cap. π«Ά
Query string parameters:
"dry_run""error_trace""explain""human""master_timeout""metric""retry_failed""timeout"
See the reroute docs <http://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-reroute.html> for more information.
π remote_info()
$response = $e->cluster->remote_info();
the remote_info() API retrieves all of the configured remote cluster information. all of it. every last crumb. π
Query string parameters:
"error_trace""human"
See the remote_info docs <https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-remote-info.html> for more information.
π«Ά AUTHOR π«Ά
Enrico Zimuel <enrico.zimuel@elastic.co> β ty for your service, king. π
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2024 by Elasticsearch BV.
This is free software, licensed under:
The Apache License, Version 2.0, January 2004
and that's the whole page, bestie!! πΈ this lil writeup came to you from perl v5.38.2, dated 2024-02-04, in the Search...Cluster(3pm) era of the docs. go forth and interrogate your cluster responsibly. πβ¨π¦
π¦ where this page comes from
- debian trixie: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu noble: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu resolute: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- ubuntu stonking: libsearch-elasticsearch-perl 8.12-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms