Commit 6ac13e2ae7c73dbaee9225c6715a45e1b3f10366

Authored by Andrew
1 parent d460d2eb

Revert "Use pluck for async reindex to avoid loading records in memory - #1134"

This reverts commit d460d2ebadaebca37111393257546c9c4a3a2417.
Showing 1 changed file with 3 additions and 5 deletions   Show diff stats
lib/searchkick/bulk_indexer.rb
... ... @@ -14,7 +14,7 @@ module Searchkick
14 14 end
15 15  
16 16 if batch
17   - import_or_update relation, method_name, async
  17 + import_or_update relation.to_a, method_name, async
18 18 Searchkick.with_redis { |r| r.srem(batches_key, batch_id) } if batch_id
19 19 elsif full && async
20 20 full_reindex_async(relation)
... ... @@ -58,13 +58,11 @@ module Searchkick
58 58 private
59 59  
60 60 def import_or_update(records, method_name, async)
61   - records = async ? records.pluck(:id) : records.to_a
62   -
63 61 if records.any?
64 62 if async
65 63 Searchkick::BulkReindexJob.perform_later(
66   - class_name: records.name,
67   - record_ids: records,
  64 + class_name: records.first.class.name,
  65 + record_ids: records.map(&:id),
68 66 index_name: index.name,
69 67 method_name: method_name ? method_name.to_s : nil
70 68 )
... ...