From 6ac13e2ae7c73dbaee9225c6715a45e1b3f10366 Mon Sep 17 00:00:00 2001 From: Andrew Date: Sat, 12 May 2018 13:08:18 -0700 Subject: [PATCH] Revert "Use pluck for async reindex to avoid loading records in memory - #1134" --- lib/searchkick/bulk_indexer.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/searchkick/bulk_indexer.rb b/lib/searchkick/bulk_indexer.rb index 451c250..580c1c9 100644 --- a/lib/searchkick/bulk_indexer.rb +++ b/lib/searchkick/bulk_indexer.rb @@ -14,7 +14,7 @@ module Searchkick end if batch - import_or_update relation, method_name, async + import_or_update relation.to_a, method_name, async Searchkick.with_redis { |r| r.srem(batches_key, batch_id) } if batch_id elsif full && async full_reindex_async(relation) @@ -58,13 +58,11 @@ module Searchkick private def import_or_update(records, method_name, async) - records = async ? records.pluck(:id) : records.to_a - if records.any? if async Searchkick::BulkReindexJob.perform_later( - class_name: records.name, - record_ids: records, + class_name: records.first.class.name, + record_ids: records.map(&:id), index_name: index.name, method_name: method_name ? method_name.to_s : nil ) -- libgit2 0.21.0