docbrown/app/workers/search/bulk_index_worker.rb
Andy Zhao e686d63d78
[deploy] Add public reactions count fields to Elasticsearch (#7956)
* Add public_reactions_count field to elasticsearch

* Add new data update scripts and update old ones

* Use BulkIndexWorker to batch indexing

* Use proper search class for handling feed content

* Remove redundant script oops

* Rename data update script and remove old specs

* Combine specs into one file
2020-05-20 13:06:48 -04:00

18 lines
446 B
Ruby

module Search
class BulkIndexWorker
include Sidekiq::Worker
sidekiq_options queue: :high_priority, lock: :until_executing
def perform(object_class, ids)
data_hashes = object_class.constantize.
eager_load_serialized_data.
where(id: ids).
find_each.map(&:serialized_search_hash)
search_class = object_class.constantize::SEARCH_CLASS
search_class.bulk_index(data_hashes)
end
end
end