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

TODO remove min_id and max_id in Searchkick 6



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

def perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil)
  model = Searchkick.load_model(class_name)
  index = model.searchkick_index(name: index_name)

  # legacy
  record_ids ||= min_id..max_id

  relation = Searchkick.scope(model)
  relation = Searchkick.load_records(relation, record_ids)
  relation = relation.search_import if relation.respond_to?(:search_import)

  RecordIndexer.new(index).reindex(relation, mode: :inline, method_name: method_name, full: false)
  RelationIndexer.new(index).batch_completed(batch_id) if batch_id
end