index

in opensearch-api/lib/opensearch/api/actions/index.rb [54:83]


      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)

        _type = arguments.delete(:type)

        method = _id ? OpenSearch::API::HTTP_PUT : OpenSearch::API::HTTP_POST
        path   = if _index && _type && _id
                   "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}/#{Utils.__listify(_id)}"
                 elsif _index && _id
                   "#{Utils.__listify(_index)}/_doc/#{Utils.__listify(_id)}"
                 elsif _index && _type
                   "#{Utils.__listify(_index)}/#{Utils.__listify(_type)}"
                 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