63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/searchkick/record_indexer.rb', line 63
def reindex_items(klass, items, method_name:, single: false)
routing = items.to_h { |r| [r[:id], r[:routing]] }
record_ids = routing.keys
relation = Searchkick.load_records(klass, record_ids)
relation = relation.search_import if relation.respond_to?(:search_import)
records = relation.select(&:should_index?)
delete_ids = record_ids - records.map { |r| r.id.to_s }
delete_records =
delete_ids.map do |id|
construct_record(klass, id, routing[id])
end
import_inline(records, delete_records, method_name: method_name, single: single)
end
|