Method: Elasticsearch::API::Indices::Actions#put_mapping
- Defined in:
- lib/elasticsearch/api/actions/indices/put_mapping.rb
#put_mapping(arguments = {}) ⇒ Object
Update field mappings. Add new fields to an existing data stream or index. You can use the update mapping API to:
-
Add a new field to an existing index
-
Update mappings for multiple indices in a single request
-
Add new properties to an object field
-
Enable multi-fields for an existing field
-
Update supported mapping parameters
-
Change a field’s mapping using reindexing
-
Rename a field using a field alias
Learn how to use the update mapping API with practical examples in the Update mapping API examples guide.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/elasticsearch/api/actions/indices/put_mapping.rb', line 65 def put_mapping(arguments = {}) request_opts = { endpoint: arguments[:endpoint] || 'indices.put_mapping' } defined_params = [:index].each_with_object({}) do |variable, set_variables| set_variables[variable] = arguments[variable] if arguments.key?(variable) end request_opts[:defined_params] = defined_params unless defined_params.empty? raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] 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)}/_mapping" params = Utils.process_params(arguments) Elasticsearch::API::Response.new( perform_request(method, path, params, body, headers, request_opts) ) end |