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,7 +17,8 @@ module Searchkick | ||
17 | raise Searchkick::Error, "Active Job not found" | 17 | raise Searchkick::Error, "Active Job not found" |
18 | end | 18 | end |
19 | 19 | ||
20 | - # temporary hack | 20 | + # we could likely combine ReindexV2Job, BulkReindexJob, and ProcessBatchJob |
21 | + # but keep them separate for now | ||
21 | if single | 22 | if single |
22 | record = records.first | 23 | record = records.first |
23 | 24 | ||
@@ -31,7 +32,8 @@ module Searchkick | @@ -31,7 +32,8 @@ module Searchkick | ||
31 | record.class.name, | 32 | record.class.name, |
32 | record.id.to_s, | 33 | record.id.to_s, |
33 | method_name ? method_name.to_s : nil, | 34 | method_name ? method_name.to_s : nil, |
34 | - routing: routing | 35 | + routing: routing, |
36 | + index_name: index.name | ||
35 | ) | 37 | ) |
36 | else | 38 | else |
37 | Searchkick::BulkReindexJob.perform_later( | 39 | Searchkick::BulkReindexJob.perform_later( |
lib/searchkick/reindex_v2_job.rb
@@ -2,15 +2,16 @@ module Searchkick | @@ -2,15 +2,16 @@ module Searchkick | ||
2 | class ReindexV2Job < ActiveJob::Base | 2 | class ReindexV2Job < ActiveJob::Base |
3 | queue_as { Searchkick.queue_name } | 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 | model = Searchkick.load_model(class_name, allow_child: true) | 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 | # use should_index? to decide whether to index (not default scope) | 8 | # use should_index? to decide whether to index (not default scope) |
8 | # just like saving inline | 9 | # just like saving inline |
9 | # could use Searchkick.scope() in future | 10 | # could use Searchkick.scope() in future |
10 | # but keep for now for backwards compatibility | 11 | # but keep for now for backwards compatibility |
11 | model = model.unscoped if model.respond_to?(:unscoped) | 12 | model = model.unscoped if model.respond_to?(:unscoped) |
12 | items = [{id: id, routing: routing}] | 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 | end | 15 | end |
15 | end | 16 | end |
16 | end | 17 | end |