Class: Searchkick::BulkReindexJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/searchkick/bulk_reindex_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/searchkick/bulk_reindex_job.rb', line 5

def perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil)
  klass = class_name.constantize
  index = index_name ? Searchkick::Index.new(index_name, **klass.searchkick_options) : klass.searchkick_index
  record_ids ||= min_id..max_id
  index.import_scope(
    Searchkick.load_records(klass, record_ids),
    method_name: method_name,
    batch: true,
    batch_id: batch_id
  )
end