Commit 1c35e45886369d8c28f6ef3e819e34c337259c23
1 parent
e21f4fec
Exists in
master
and in
2 other branches
Added index_name to ReindexV2Job [skip ci]
Showing
2 changed files
with
7 additions
and
4 deletions
Show diff stats
lib/searchkick/record_indexer.rb
... | ... | @@ -17,7 +17,8 @@ module Searchkick |
17 | 17 | raise Searchkick::Error, "Active Job not found" |
18 | 18 | end |
19 | 19 | |
20 | - # temporary hack | |
20 | + # we could likely combine ReindexV2Job, BulkReindexJob, and ProcessBatchJob | |
21 | + # but keep them separate for now | |
21 | 22 | if single |
22 | 23 | record = records.first |
23 | 24 | |
... | ... | @@ -31,7 +32,8 @@ module Searchkick |
31 | 32 | record.class.name, |
32 | 33 | record.id.to_s, |
33 | 34 | method_name ? method_name.to_s : nil, |
34 | - routing: routing | |
35 | + routing: routing, | |
36 | + index_name: index.name | |
35 | 37 | ) |
36 | 38 | else |
37 | 39 | Searchkick::BulkReindexJob.perform_later( | ... | ... |
lib/searchkick/reindex_v2_job.rb
... | ... | @@ -2,15 +2,16 @@ module Searchkick |
2 | 2 | class ReindexV2Job < ActiveJob::Base |
3 | 3 | queue_as { Searchkick.queue_name } |
4 | 4 | |
5 | - def perform(class_name, id, method_name = nil, routing: nil) | |
5 | + def perform(class_name, id, method_name = nil, routing: nil, index_name: nil) | |
6 | 6 | model = Searchkick.load_model(class_name, allow_child: true) |
7 | + index = index_name ? Searchkick::Index.new(index_name, model.searchkick_options) : model.searchkick_index | |
7 | 8 | # use should_index? to decide whether to index (not default scope) |
8 | 9 | # just like saving inline |
9 | 10 | # could use Searchkick.scope() in future |
10 | 11 | # but keep for now for backwards compatibility |
11 | 12 | model = model.unscoped if model.respond_to?(:unscoped) |
12 | 13 | items = [{id: id, routing: routing}] |
13 | - model.searchkick_index.send(:record_indexer).reindex_items(model, items, method_name: method_name, single: true) | |
14 | + index.send(:record_indexer).reindex_items(model, items, method_name: method_name, single: true) | |
14 | 15 | end |
15 | 16 | end |
16 | 17 | end | ... | ... |