module ES::Index::Model

Public Instance Methods

update_es_index(options={}) click to toggle source
# File lib/es/index/model.rb, line 17
def update_es_index(options={})
  if self.class.es_if.nil? || self.class.es_if.call(self)
    index_req = {
      index: (options[:index_name] || self.class.es_index),
      type: self.class.es_type,
      id: self.class.es_id.call(self),
      body: self.class.to_es_json.call(self),
    }
    index_req.merge!(:ttl => self.class.es_ttl.call(self)) if self.class.es_ttl
    ES::Index::Client.connection.index(index_req)
  end
end