Commit 4227974dcb5cf7541dc862bef47a7103a49c0d73
1 parent
2321a81e
Exists in
reindex_refactor
Updated
Showing
2 changed files
with
7 additions
and
3 deletions
Show diff stats
lib/searchkick/bulk_reindex_job.rb
... | ... | @@ -6,12 +6,12 @@ module Searchkick |
6 | 6 | klass = class_name.constantize |
7 | 7 | index = index_name ? Searchkick::Index.new(index_name, **klass.searchkick_options) : klass.searchkick_index |
8 | 8 | record_ids ||= min_id..max_id |
9 | - index.import_scope( | |
9 | + RecordIndexer.new(index).reindex_records( | |
10 | 10 | Searchkick.load_records(klass, record_ids), |
11 | 11 | method_name: method_name, |
12 | - batch: true, | |
13 | - batch_id: batch_id | |
12 | + mode: :inline | |
14 | 13 | ) |
14 | + Searchkick.with_redis { |r| r.srem(index.send(:bulk_indexer).send(:batches_key), batch_id) } if batch_id | |
15 | 15 | end |
16 | 16 | end |
17 | 17 | end | ... | ... |
lib/searchkick/record_indexer.rb
... | ... | @@ -56,9 +56,13 @@ module Searchkick |
56 | 56 | ) |
57 | 57 | end |
58 | 58 | else # bulk, inline/true/nil |
59 | + relation = relation.search_import if relation.respond_to?(:search_import) | |
60 | + | |
59 | 61 | delete_records, index_records = records.partition { |r| r.destroyed? || !r.persisted? || !r.should_index? } |
60 | 62 | |
61 | 63 | # TODO use |
64 | + # Searchkick.callbacks(:bulk) | |
65 | + # and | |
62 | 66 | # index.bulk_delete(delete_records) |
63 | 67 | delete_records.each do |record| |
64 | 68 | begin | ... | ... |