Sha256: 3ac69b0cecb1210110af64937fdea92cd56713714ea841aa3696d02da2fd0b64
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
# frozen_string_literal: true 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.0.0 | lib/elasticity/bulk.rb |
es-elasticity-1.0.0.jhumphreys | lib/elasticity/bulk.rb |