Class: Elasticity::Bulk
- Inherits:
-
Object
- Object
- Elasticity::Bulk
- Defined in:
- lib/elasticity/bulk.rb
Defined Under Namespace
Instance Method Summary collapse
- #delete(index_name, id) ⇒ Object
- #execute ⇒ Object
- #index(index_name, id, attributes) ⇒ Object
-
#initialize(client) ⇒ Bulk
constructor
A new instance of Bulk.
- #update(index_name, id, attributes) ⇒ Object
Constructor Details
#initialize(client) ⇒ Bulk
Returns a new instance of Bulk.
3 4 5 6 |
# File 'lib/elasticity/bulk.rb', line 3 def initialize(client) @client = client @operations = [] end |
Instance Method Details
#delete(index_name, id) ⇒ Object
16 17 18 |
# File 'lib/elasticity/bulk.rb', line 16 def delete(index_name, id) @operations << { delete: { _index: index_name, _id: id }} end |
#execute ⇒ Object
20 21 22 |
# File 'lib/elasticity/bulk.rb', line 20 def execute @client.bulk(body: @operations) end |
#index(index_name, id, attributes) ⇒ Object
8 9 10 |
# File 'lib/elasticity/bulk.rb', line 8 def index(index_name, id, attributes) @operations << { index: { _index: index_name, _id: id, data: attributes }} end |
#update(index_name, id, attributes) ⇒ Object
12 13 14 |
# File 'lib/elasticity/bulk.rb', line 12 def update(index_name, id, attributes) @operations << { update: { _index: index_name, _id: id, data: attributes }} end |