Method: Elasticsearch::Model::Indexing::InstanceMethods#update_document_attributes

Defined in:
lib/elasticsearch/model/indexing.rb

#update_document_attributes(attributes, options = {}) ⇒ Hash

Perform a partial update of specific document attributes (without consideration for changed attributes as in #update_document)

Examples:

Update the title attribute


@article = Article.first
@article.title = "New title"
@article.__elasticsearch__.update_document_attributes title: "New title"

Parameters:

  • attributes (Hash)

    Attributes to be updated

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

    Optional arguments for passing to the client

Returns:

  • (Hash)

    The response from Elasticsearch



448
449
450
451
452
453
454
# File 'lib/elasticsearch/model/indexing.rb', line 448

def update_document_attributes(attributes, options={})
  request = { index: index_name,
              id:    self.id,
              body:  { doc: attributes } }

  client.update(request.merge!(options))
end