Method: Elasticsearch::API::Indices::Actions#create

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

#create(arguments = {}) ⇒ Object

Creates an index with optional settings and mappings.

Parameters:

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

    a customizable set of options

Options Hash (arguments):

  • :index (String)

    The name of the index

  • :wait_for_active_shards (String)

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

  • :timeout (Time)

    Explicit operation timeout

  • :master_timeout (Time)

    Specify timeout for connection to master

  • :headers (Hash)

    Custom HTTP headers

  • :body (Hash)

    The configuration for the index (settings and mappings)

Raises:

  • (ArgumentError)

See Also:



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

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

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

  body   = arguments.delete(:body)

  _index = arguments.delete(:index)

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

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