Method: OpenSearch::API::Actions#index
- Defined in:
- lib/opensearch/api/actions/index.rb
#index(arguments = {}) ⇒ Object
Creates or updates a document in an index.
*Deprecation notice*: Specifying types in urls has been deprecated Deprecated since version 7.0.0
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/opensearch/api/actions/index.rb', line 54 def index(arguments = {}) raise ArgumentError, "Required argument 'body' missing" unless arguments[:body] raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] headers = arguments.delete(:headers) || {} arguments = arguments.clone _id = arguments.delete(:id) _index = arguments.delete(:index) method = _id ? OpenSearch::API::HTTP_PUT : OpenSearch::API::HTTP_POST path = if _index && _id "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}" else "#{Utils.__listify(_index)}/_doc" end params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) body = arguments[:body] perform_request(method, path, params, body, headers).body end |