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,12 +6,12 @@ module Searchkick | ||
6 | klass = class_name.constantize | 6 | klass = class_name.constantize |
7 | index = index_name ? Searchkick::Index.new(index_name, **klass.searchkick_options) : klass.searchkick_index | 7 | index = index_name ? Searchkick::Index.new(index_name, **klass.searchkick_options) : klass.searchkick_index |
8 | record_ids ||= min_id..max_id | 8 | record_ids ||= min_id..max_id |
9 | - index.import_scope( | 9 | + RecordIndexer.new(index).reindex_records( |
10 | Searchkick.load_records(klass, record_ids), | 10 | Searchkick.load_records(klass, record_ids), |
11 | method_name: method_name, | 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 | end | 15 | end |
16 | end | 16 | end |
17 | end | 17 | end |
lib/searchkick/record_indexer.rb
@@ -56,9 +56,13 @@ module Searchkick | @@ -56,9 +56,13 @@ module Searchkick | ||
56 | ) | 56 | ) |
57 | end | 57 | end |
58 | else # bulk, inline/true/nil | 58 | else # bulk, inline/true/nil |
59 | + relation = relation.search_import if relation.respond_to?(:search_import) | ||
60 | + | ||
59 | delete_records, index_records = records.partition { |r| r.destroyed? || !r.persisted? || !r.should_index? } | 61 | delete_records, index_records = records.partition { |r| r.destroyed? || !r.persisted? || !r.should_index? } |
60 | 62 | ||
61 | # TODO use | 63 | # TODO use |
64 | + # Searchkick.callbacks(:bulk) | ||
65 | + # and | ||
62 | # index.bulk_delete(delete_records) | 66 | # index.bulk_delete(delete_records) |
63 | delete_records.each do |record| | 67 | delete_records.each do |record| |
64 | begin | 68 | begin |