module Elasticsearch::Model::Indexing::InstanceMethods

Public Instance Methods

update_document(options = {}) click to toggle source
# 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