Created
August 2, 2016 10:26
-
-
Save AlfonsoUceda/918d737cf5e4b6242ea4f848ae6a3485 to your computer and use it in GitHub Desktop.
partial_reindex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'progressbar' | |
schedulings = Company.find_by_name("SPT").schedulings.preloads_for_indexing | |
@progress = ProgressBar.new('Processing schedulings', schedulings.count) | |
start_now = Time.now | |
puts "Started at: #{start_now}" | |
schedulings.find_each do |scheduling| | |
Scheduling.__elasticsearch__.client.update( | |
index: Scheduling.index_name, | |
type: "scheduling", | |
id: scheduling.id, | |
body: { | |
"doc" => { | |
"metadata" => scheduling.serialized_metadata | |
} | |
} | |
) | |
@progress.inc | |
end | |
@progress.finish | |
finish_now = Time.now | |
puts "Finished at: #{finish_now}" | |
result = finish_now - start_now |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment