Sha256: faa2a6e883b31c463ac56400719416ff8ae21b17cec6ea1c9c6e2c56765bb22b
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
module Elasticity class Bulk def initialize(client) @client = client @operations = [] end def index(index_name, id, attributes) @operations << { index: { _index: index_name, _id: id, data: attributes }} end def update(index_name, id, attributes) @operations << { update: { _index: index_name, _id: id, data: attributes }} end def delete(index_name, id) @operations << { delete: { _index: index_name, _id: id }} end def execute @client.bulk(body: @operations) end class Index < Bulk def initialize(client, index_name) super(client) @index_name = index_name end def index(id, attributes) super(@index_name, id, attributes) end def update(id, attributes) super(@index_name, id, attributes) end def delete(id) super(@index_name, id) end end class Alias < Bulk def initialize(client, update_alias, delete_indexes) super(client) @update_alias = update_alias @delete_indexes = delete_indexes end def index(id, attributes) super(@update_alias, id, attributes) end def update(id, attributes) super(@update_alias, id, attributes) end def delete(id) @delete_indexes.each do |index| super(index, id) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
es-elasticity-1.1.0 | lib/elasticity/bulk.rb |
es-elasticity-1.0.1 | lib/elasticity/bulk.rb |