karmi/tire — pull request #853 by ryansch (2013-08-29 14:24:06+00:00)
Title: Add support for bulk update

This pull adds support for elasticsearch's new (since 0.90.1) bulk update endpoint.

I'm using it in our application with the following code to add an updated_at timestamp to our Contact model.

```ruby
# update mapping
index = Tire::Index.new(Contact.tire.index_name)
puts index.mapping(
Contact.tire.document_type,
properties: {
updated_at: {
type: 'date',
format: 'date_time_no_millis'
}
}
)

# add data
Contact.find_in_batches do |batch|
documents = batch.map do |contact|
{
id: contact.id,
type: Contact.tire.document_type,
_routing: contact.account_id,
doc: ContactSearchSerializer.new(contact, only: :updated_at).as_json
}
end
puts index.bulk_update(documents)
end
```