lib/gummi/db_layer/document.rb in gummi-0.3.8 vs lib/gummi/db_layer/document.rb in gummi-0.3.9
- old
+ new
@@ -33,9 +33,19 @@
delete! *args
rescue ::Elasticsearch::Transport::Transport::Errors::NotFound
nil
end
+ def update(id, attributes)
+ return unless id.present?
+ if parent_id_attribute_name && parent_id = self.send(parent_id_attribute_name)
+ options = { parent: parent_id }
+ else
+ options = {}
+ end
+ response = Hashie::Mash.new client.update options.merge(index: index.name, type: document_type, id: id, body: { doc: attributes })
+ response.ok
+ end
def delete_children_by_query(parent_id, children_query)
parent_id_query = { term: { _parent: parent_id } }
query = { bool: { must: [parent_id_query, children_query] } }
delete_by_query query