Module: Elasticsearch::Model::Indexing::InstanceMethods

Includes:
PrecheckAspect
Defined in:
lib/elasticsearch/model/indexing_decorator.rb

Instance Method Summary collapse

Methods included from PrecheckAspect

#delete_document, #index_document, #update_document_attributes

Instance Method Details

#update_document(options = {}) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/elasticsearch/model/indexing_decorator.rb', line 31

def update_document options = {}
  if changed_attributes = self.instance_variable_get(:@__changed_attributes)
    attributes = if target.respond_to? :elasticsearch_json_changes
                   target.elasticsearch_json_changes changed_attributes
                 elsif respond_to?(:as_indexed_json)
                   self.as_indexed_json.select { |k,v| changed_attributes.keys.map(&:to_s).include? k.to_s }
                 else
                   changed_attributes
                 end

    update_document_attributes attributes, options
  else
    index_document(options)
  end
end