Commit 2cf1c444a983e2ccb4cdfb0ce2fc12152217b439
1 parent
548ea14d
Exists in
master
and in
2 other branches
Use index cache for all jobs [skip ci]
Showing
3 changed files
with
4 additions
and
3 deletions
Show diff stats
lib/searchkick/bulk_reindex_job.rb
... | ... | @@ -5,7 +5,7 @@ module Searchkick |
5 | 5 | # TODO remove min_id and max_id in Searchkick 6 |
6 | 6 | def perform(class_name:, record_ids: nil, index_name: nil, method_name: nil, batch_id: nil, min_id: nil, max_id: nil) |
7 | 7 | model = Searchkick.load_model(class_name) |
8 | - index = index_name ? Searchkick::Index.new(index_name, model.searchkick_options) : model.searchkick_index | |
8 | + index = model.searchkick_index(name: index_name) | |
9 | 9 | |
10 | 10 | # legacy |
11 | 11 | record_ids ||= min_id..max_id | ... | ... |
lib/searchkick/process_queue_job.rb
... | ... | @@ -4,10 +4,11 @@ module Searchkick |
4 | 4 | |
5 | 5 | def perform(class_name:, index_name: nil, inline: false) |
6 | 6 | model = Searchkick.load_model(class_name) |
7 | + index = model.searchkick_index(name: index_name) | |
7 | 8 | limit = model.searchkick_options[:batch_size] || 1000 |
8 | 9 | |
9 | 10 | loop do |
10 | - record_ids = model.searchkick_index(name: index_name).reindex_queue.reserve(limit: limit) | |
11 | + record_ids = index.reindex_queue.reserve(limit: limit) | |
11 | 12 | if record_ids.any? |
12 | 13 | batch_options = { |
13 | 14 | class_name: class_name, | ... | ... |
lib/searchkick/reindex_v2_job.rb
... | ... | @@ -4,7 +4,7 @@ module Searchkick |
4 | 4 | |
5 | 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 | + index = model.searchkick_index(name: index_name) | |
8 | 8 | # use should_index? to decide whether to index (not default scope) |
9 | 9 | # just like saving inline |
10 | 10 | # could use Searchkick.scope() in future | ... | ... |