Class: Elasticity::Bulk

Inherits:
Object
  • Object
show all
Defined in:
lib/elasticity/bulk.rb

Direct Known Subclasses

Alias, Index

Defined Under Namespace

Classes: Alias, Index

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ 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, type, id) ⇒ Object


12
13
14
# File 'lib/elasticity/bulk.rb', line 12

def delete(index_name, type, id)
  @operations << { delete: { _index: index_name, _type: type, _id: id }}
end

#executeObject


16
17
18
# File 'lib/elasticity/bulk.rb', line 16

def execute
  @client.bulk(body: @operations)
end

#index(index_name, type, id, attributes) ⇒ Object


8
9
10
# File 'lib/elasticity/bulk.rb', line 8

def index(index_name, type, id, attributes)
  @operations << { index: { _index: index_name, _type: type, _id: id, data: attributes }}
end