Method: Elasticsearch::API::Indices::Actions#clone

Defined in:
lib/elasticsearch/api/actions/indices/clone.rb

#clone(arguments = {}) ⇒ Object

Clones an index

Parameters:

  • arguments (Hash) (defaults to: {})

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The name of the source index to clone

  • :target (String)

    The name of the target index to clone into

  • :timeout (Time)

    Explicit operation timeout

  • :master_timeout (Time)

    Specify timeout for connection to master

  • :wait_for_active_shards (String)

    Set the number of active shards to wait for on the cloned index before the operation returns.

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The configuration for the target index (‘settings` and `aliases`)

Raises:

  • (ArgumentError)

See Also:


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/elasticsearch/api/actions/indices/clone.rb', line 37

def clone(arguments = {})
  raise ArgumentError, "Required argument 'index' missing" unless arguments[:index]
  raise ArgumentError, "Required argument 'target' missing" unless arguments[:target]

  arguments = arguments.clone
  headers = arguments.delete(:headers) || {}

  body   = arguments.delete(:body)

  _index = arguments.delete(:index)

  _target = arguments.delete(:target)

  method = Elasticsearch::API::HTTP_PUT
  path   = "#{Utils.__listify(_index)}/_clone/#{Utils.__listify(_target)}"
  params = Utils.process_params(arguments)

  Elasticsearch::API::Response.new(
    perform_request(method, path, params, body, headers)
  )
end