class Elastictastic::MultiGet
Public Class Methods
new()
click to toggle source
# File lib/elastictastic/multi_get.rb, line 7 def initialize @docspecs = [] @scopes = [] end
Public Instance Methods
add(scope, *ids)
click to toggle source
# File lib/elastictastic/multi_get.rb, line 12 def add(scope, *ids) scope = scope.all params = scope.multi_get_params ids.flatten.each do |id| @docspecs << params.merge('_id' => id.to_s) @scopes << scope end end
each() { |materialize_hit| ... }
click to toggle source
# File lib/elastictastic/multi_get.rb, line 21 def each return if @docspecs.empty? Elastictastic.client.mget(@docspecs)['docs'].zip(@scopes) do |hit, scope| yield scope.materialize_hit(hit) if hit['exists'] end end