Module: EsClient::ActiveRecord::Glue::ClassMethods
- Defined in:
- lib/es_client/active_record/glue.rb
Instance Method Summary collapse
- #es_client_reindex(options = {}) ⇒ Object
- #es_client_reindex_with_progress(options = {}) ⇒ Object
- #find_in_batches_with_progress(options = {}) ⇒ Object
Instance Method Details
#es_client_reindex(options = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/es_client/active_record/glue.rb', line 41 def es_client_reindex(={}) find_in_batches() do |batch| es_client.import(batch) end end |
#es_client_reindex_with_progress(options = {}) ⇒ Object
47 48 49 50 51 |
# File 'lib/es_client/active_record/glue.rb', line 47 def es_client_reindex_with_progress(={}) find_in_batches_with_progress() do |batch| es_client.import(batch) end end |
#find_in_batches_with_progress(options = {}) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/es_client/active_record/glue.rb', line 53 def find_in_batches_with_progress( = {}) unless defined? ProgressBar warn "Install 'ruby-progressbar' gem to use '#{__method__}' method" return end [:batch_size] ||= 1000 total = (count / [:batch_size].to_f).ceil title = .delete(:name) || "#{name} batch_size:#{[:batch_size]}" = ProgressBar.create(title: title, total: total, format: '%c of %C - %a %e |%b>>%i| %p%% %t') .progress_mark = '=' find_in_batches() do |r| yield r .increment end .finish end |