diff --git a/lib/searchkick/bulk_reindex_job.rb b/lib/searchkick/bulk_reindex_job.rb index 0c48f55..78b23bc 100644 --- a/lib/searchkick/bulk_reindex_job.rb +++ b/lib/searchkick/bulk_reindex_job.rb @@ -6,12 +6,12 @@ module Searchkick klass = class_name.constantize index = index_name ? Searchkick::Index.new(index_name, **klass.searchkick_options) : klass.searchkick_index record_ids ||= min_id..max_id - index.import_scope( + RecordIndexer.new(index).reindex_records( Searchkick.load_records(klass, record_ids), method_name: method_name, - batch: true, - batch_id: batch_id + mode: :inline ) + Searchkick.with_redis { |r| r.srem(index.send(:bulk_indexer).send(:batches_key), batch_id) } if batch_id end end end diff --git a/lib/searchkick/record_indexer.rb b/lib/searchkick/record_indexer.rb index 38c2b83..158de9f 100644 --- a/lib/searchkick/record_indexer.rb +++ b/lib/searchkick/record_indexer.rb @@ -56,9 +56,13 @@ module Searchkick ) end else # bulk, inline/true/nil + relation = relation.search_import if relation.respond_to?(:search_import) + delete_records, index_records = records.partition { |r| r.destroyed? || !r.persisted? || !r.should_index? } # TODO use + # Searchkick.callbacks(:bulk) + # and # index.bulk_delete(delete_records) delete_records.each do |record| begin -- libgit2 0.21.0