Method: Elasticsearch::API::Actions#update
- Defined in:
- lib/elasticsearch/api/actions/update.rb
#update(arguments = {}) ⇒ Object
Update a document without sending the whole document in the request (“partial update”).
Send either a partial document (doc ) which will be deeply merged into an existing document, or a script, which will update the document content, in the :body argument.
The partial update operation allows you to limit the amount of data you send over the wire and reduces the chance of failed updates due to conflict.
Specify the :version and :retry_on_conflict arguments to balance convenience and consistency.
64 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 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/elasticsearch/api/actions/update.rb', line 64 def update(arguments={}) raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] raise ArgumentError, "Required argument 'type' missing" unless arguments[:type] raise ArgumentError, "Required argument 'id' missing" unless arguments[:id] valid_params = [ :consistency, :fields, :lang, :parent, :percolate, :refresh, :replication, :retry_on_conflict, :routing, :script, :timeout, :timestamp, :ttl, :version, :version_type ] method = HTTP_POST path = Utils.__pathify Utils.__escape(arguments[:index]), Utils.__escape(arguments[:type]), Utils.__escape(arguments[:id]), '_update' params = Utils.__validate_and_extract_params arguments, valid_params body = arguments[:body] params[:fields] = Utils.__listify(params[:fields]) if params[:fields] if Array(arguments[:ignore]).include?(404) Utils.__rescue_from_not_found { perform_request(method, path, params, body).body } else perform_request(method, path, params, body).body end end |