28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/runes/orm/active_record.rb', line 28
def add_object_to_index
begin
if $es_client.search("_id: #{self.id}", :index => self.class.index_name, :type => self.class.type_name).hits == []
$es_client.index(self.to_json, :id => self.id, :index => self.class.index_name, :type => self.class.type_name)
else
return true
end
rescue ElasticSearch::RequestError
$es_client.index(self.to_json, :id => self.id, :index => self.class.index_name, :type => self.class.type_name)
end
end
|