Files

Elasticsearch::API::Cluster::Actions

Public Instance Methods

get_settings(arguments={}) click to toggle source

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)

@see elasticsearch.org/guide/reference/api/admin-cluster-update-settings/

# File lib/elasticsearch/api/actions/cluster/get_settings.rb, line 16
def get_settings(arguments={})
  valid_params = [
    :flat_settings
  ]

  method = 'GET'
  path   = "_cluster/settings"
  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
health(arguments={}) click to toggle source

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 [String] :wait_for_status Wait until cluster is in a specific state

(options: green, yellow, red)

@see elasticsearch.org/guide/reference/api/admin-cluster-health/

# File lib/elasticsearch/api/actions/cluster/health.rb, line 32
def health(arguments={})
  valid_params = [
    :level,
    :local,
    :master_timeout,
    :timeout,
    :wait_for_active_shards,
    :wait_for_nodes,
    :wait_for_relocating_shards,
    :wait_for_status ]

  method = 'GET'
  path   = "_cluster/health"

  params = Utils.__validate_and_extract_params arguments, valid_params
  body = nil

  perform_request(method, path, params, body).body
end
pending_tasks(arguments={}) click to toggle source

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 = 'GET'
  path   = "/_cluster/pending_tasks"
  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = nil

  perform_request(method, path, params, body).body
end
put_settings(arguments={}) click to toggle source

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 = 'PUT'
  path   = "_cluster/settings"
  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = arguments[:body] || {}

  perform_request(method, path, params, body).body
end
reroute(arguments={}) click to toggle source

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 explicitely 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] :filter_metadata Don’t return cluster state metadata (default: false)

@see elasticsearch.org/guide/reference/api/admin-cluster-reroute/

# File lib/elasticsearch/api/actions/cluster/reroute.rb, line 29
def reroute(arguments={})
  valid_params = [ :dry_run, :explain, :filter_metadata ]

  method = 'POST'
  path   = "_cluster/reroute"

  params = Utils.__validate_and_extract_params arguments, valid_params
  body   = arguments[:body] || {}

  perform_request(method, path, params, body).body
end
state(arguments={}) click to toggle source

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

@see elasticsearch.org/guide/reference/api/admin-cluster-state/

# File lib/elasticsearch/api/actions/cluster/state.rb, line 25
def state(arguments={})
  arguments = arguments.clone
  index     = arguments.delete(:index)
  metric    = arguments.delete(:metric)

  valid_params = [
    :metric,
    :index_templates,
    :local,
    :master_timeout,
    :flat_settings ]

  method = '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

[Validate]

Generated with the Darkfish Rdoc Generator 2.