module Elasticsearch::API::Cluster::Actions
Public Instance Methods
Return the information about why a shard is or isn't allocated
@option arguments [Hash] :body The index, shard, and primary flag to explain. Empty means 'explain the first unassigned shard' @option arguments [Boolean] :include_yes_decisions Return 'YES' decisions in explanation (default: false) @option arguments [Boolean] :include_disk_info Return information about disk usage and shard sizes
(default: false)
@see www.elastic.co/guide/en/elasticsearch/reference/master/cluster-allocation-explain.html
# File lib/elasticsearch/api/actions/cluster/allocation_explain.rb, line 15 def allocation_explain(arguments={}) valid_params = [ :include_yes_decisions, :include_disk_info ] method = 'GET' path = "_cluster/allocation/explain" params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] perform_request(method, path, params, body).body end
Get the cluster settings (previously set with {Cluster::Actions#put_settings})
@example Get cluster settings
client.cluster.get_settings
@option arguments [Boolean] :flat_settings Return settings in flat format (default: false) @option arguments [Boolean] :include_defaults Whether to return all default clusters setting
(default: false)
@see elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
# File lib/elasticsearch/api/actions/cluster/get_settings.rb, line 18 def get_settings(arguments={}) valid_params = [ :flat_settings, :include_defaults ] method = HTTP_GET path = "_cluster/settings" params = Utils.__validate_and_extract_params arguments, valid_params body = nil perform_request(method, path, params, body).body end
Returns information about cluster “health”.
@example Get the cluster health information
client.cluster.health
@example Block the request until the cluster is in the “yellow” state
client.cluster.health wait_for_status: 'yellow'
@option arguments [String] :index Limit the information returned to a specific index @option arguments [String] :level Specify the level of detail for returned information
(options: cluster, indices, shards)
@option arguments [Boolean] :local Return local information, do not retrieve the state from master node
(default: false)
@option arguments [Time] :master_timeout Explicit operation timeout for connection to master node @option arguments [Time] :timeout Explicit operation timeout @option arguments [Number] :wait_for_active_shards Wait until the specified number of shards is active @option arguments [Number] :wait_for_nodes Wait until the specified number of nodes is available @option arguments [Number] :wait_for_relocating_shards Wait until the specified number of relocating
shards is finished
@option arguments [Boolean] :wait_for_no_relocating_shards Whether to wait until there are no relocating
shards in the cluster
@option arguments [String] :wait_for_status Wait until cluster is in a specific state
(options: green, yellow, red)
@option arguments [List] :wait_for_events Wait until all currently queued events with the given priorty
are processed (immediate, urgent, high, normal, low, languid)
@see elasticsearch.org/guide/reference/api/admin-cluster-health/
# File lib/elasticsearch/api/actions/cluster/health.rb, line 36 def health(arguments={}) arguments = arguments.clone index = arguments.delete(:index) valid_params = [ :level, :local, :master_timeout, :timeout, :wait_for_active_shards, :wait_for_nodes, :wait_for_relocating_shards, :wait_for_no_relocating_shards, :wait_for_status, :wait_for_events ] method = HTTP_GET path = Utils.__pathify "_cluster/health", Utils.__listify(index) params = Utils.__validate_and_extract_params arguments, valid_params body = nil perform_request(method, path, params, body).body end
Returns a list of any cluster-level changes (e.g. create index, update mapping, allocate or fail shard) which have not yet been executed and are queued up.
@example Get a list of currently queued up tasks in the cluster
client.cluster.pending_tasks
@option arguments [Boolean] :local Return local information, do not retrieve the state from master node
(default: false)
@option arguments [Time] :master_timeout Specify timeout for connection to master
@see www.elasticsearch.org/guide/en/elasticsearch/reference/master/cluster-pending.html
# File lib/elasticsearch/api/actions/cluster/pending_tasks.rb, line 19 def pending_tasks(arguments={}) valid_params = [ :local, :master_timeout ] method = HTTP_GET path = "_cluster/pending_tasks" params = Utils.__validate_and_extract_params arguments, valid_params body = nil perform_request(method, path, params, body).body end
Update cluster settings.
@example Disable shard allocation in the cluster until restart
client.cluster.put_settings body: { transient: { 'cluster.routing.allocation.disable_allocation' => true } }
@option arguments [Hash] :body The settings to be updated. Can be either `transient` or `persistent`
(survives cluster restart).
@see elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
# File lib/elasticsearch/api/actions/cluster/put_settings.rb, line 17 def put_settings(arguments={}) valid_params = [ :flat_settings ] method = HTTP_PUT path = "_cluster/settings" params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] || {} perform_request(method, path, params, body).body end
Perform manual shard allocation in the cluster.
Pass the operations you want to perform in the `:body` option. Use the `dry_run` option to evaluate the result of operations without actually performing them.
@example Move shard `0` of index `myindex` from node named Node1 to node named Node2
client.cluster.reroute body: { commands: [ { move: { index: 'myindex', shard: 0, from_node: 'Node1', to_node: 'Node2' } } ] }
@note If you want to explicitly set the shard allocation to a certain node, you might
want to look at the `allocation.*` cluster settings.
@option arguments [Hash] :body The definition of `commands` to perform (`move`, `cancel`, `allocate`) @option arguments [Boolean] :dry_run Simulate the operation only and return the resulting state @option arguments [Boolean] :explain Return an explanation for why the commands can or cannot be executed @option arguments [Boolean] :metric Limit the information returned to the specified metrics.
Defaults to all but metadata. (Options: _all, blocks, metadata, nodes, routing_table, master_node, version)
@option arguments [Time] :master_timeout Specify timeout for connection to master @option arguments [Boolean] :retry_failed Retries allocation of shards that are blocked due to too many
subsequent allocation failures
@see elasticsearch.org/guide/reference/api/admin-cluster-reroute/
# File lib/elasticsearch/api/actions/cluster/reroute.rb, line 34 def reroute(arguments={}) valid_params = [ :dry_run, :explain, :metric, :master_timeout, :retry_failed, :timeout ] method = HTTP_POST path = "_cluster/reroute" params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] || {} perform_request(method, path, params, body).body end
Get information about the cluster state (indices settings, allocations, etc)
@example
client.cluster.state
@option arguments [List] :index A comma-separated list of index names; use `_all` or omit to
perform the operation on all indices
@option arguments [List] :metric Limit the information returned to the specified metrics
(options: _all, blocks, index_templates, metadata, nodes, routing_table, master_node, version)
@option arguments [List] :index_templates A comma separated list to return specific index templates when
returning metadata
@option arguments [Boolean] :local Return local information, do not retrieve the state from master node
(default: false)
@option arguments [Time] :master_timeout Specify timeout for connection to master @option arguments [String] :expand_wildcards Whether to expand wildcard expression for inidices
(options: open, closed)
@option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when
unavailable (missing, closed, etc)
@see elasticsearch.org/guide/reference/api/admin-cluster-state/
# File lib/elasticsearch/api/actions/cluster/state.rb, line 29 def state(arguments={}) arguments = arguments.clone index = arguments.delete(:index) metric = arguments.delete(:metric) valid_params = [ :metric, :index_templates, :local, :master_timeout, :flat_settings, :expand_wildcards, :ignore_unavailable ] method = HTTP_GET path = "_cluster/state" path = Utils.__pathify '_cluster/state', Utils.__listify(metric), Utils.__listify(index) params = Utils.__validate_and_extract_params arguments, valid_params [:index_templates].each do |key| params[key] = Utils.__listify(params[key]) if params[key] end body = nil perform_request(method, path, params, body).body end
Returns statistical information about the cluster
@option arguments [List] :node_id A comma-separated list of node IDs or names to limit the returned information; use `_local` to return information from the node you're connecting to, leave empty to get information from all nodes @option arguments [Boolean] :flat_settings Return settings in flat format (default: false) @option arguments [Boolean] :human Whether to return time and byte values in human-readable format. @option arguments [Time] :timeout Explicit operation timeout
@see www.elastic.co/guide/en/elasticsearch/reference/master/cluster-stats.html
# File lib/elasticsearch/api/actions/cluster/stats.rb, line 15 def stats(arguments={}) valid_params = [ :flat_settings, :human, :timeout ] method = 'GET' path = "_cluster/stats" params = Utils.__validate_and_extract_params arguments, valid_params body = nil perform_request(method, path, params, body).body end