7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/esse/async_indexing/actions/batch_update.rb', line 7
def self.call(index_class_name, repo_name, ids, options = {})
ids = Array(ids)
return if ids.empty?
index_class, repo_class = CoerceIndexRepository.call(index_class_name, repo_name)
bulk_opts = Esse::HashUtils.deep_transform_keys(options, &:to_sym)
find_opts = {}
if (context = bulk_opts.delete(:context))
find_opts.merge!(context)
end
if (lazy_attributes = bulk_opts.delete(:lazy_attributes))
find_opts[:lazy_attributes] = lazy_attributes
end
find_opts[:id] = ids
count = 0
repo_class.each_serialized_batch(**find_opts) do |batch|
index_class.cluster.may_update_type!(bulk_opts)
index_class.bulk(**bulk_opts, update: batch)
count += batch.size
end
count
end
|