Module: Elasticsearch::Model::Extensions::BatchUpdating::ClassMethods
- Defined in:
- lib/elasticsearch/model/extensions/batch_updating.rb
Instance Method Summary collapse
- #__batch_updater__ ⇒ Object
- #for_batch_indexing ⇒ Object
- #for_indexing ⇒ Object
- #update_index_in_batches(batch_size: DEFAULT_BATCH_SIZE, where: nil, index: nil, type: nil) ⇒ Object
- #update_index_in_parallel(parallelism:, index: nil, type: nil, min: nil, max: nil, batch_size: DEFAULT_BATCH_SIZE) ⇒ Object
Instance Method Details
#__batch_updater__ ⇒ Object
31 32 33 |
# File 'lib/elasticsearch/model/extensions/batch_updating.rb', line 31 def __batch_updater__ @__batch_updater__ ||= ::Elasticsearch::Model::Extensions::BatchUpdating::BatchUpdater.new(self) end |
#for_batch_indexing ⇒ Object
50 51 52 |
# File 'lib/elasticsearch/model/extensions/batch_updating.rb', line 50 def for_batch_indexing with_indexed_tables_included.extending(::Elasticsearch::Model::Extensions::BatchUpdating::Association::Extension) end |
#for_indexing ⇒ Object
46 47 48 |
# File 'lib/elasticsearch/model/extensions/batch_updating.rb', line 46 def for_indexing for_batch_indexing end |
#update_index_in_batches(batch_size: DEFAULT_BATCH_SIZE, where: nil, index: nil, type: nil) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/elasticsearch/model/extensions/batch_updating.rb', line 55 def update_index_in_batches(batch_size: DEFAULT_BATCH_SIZE, where: nil, index: nil, type: nil) records_in_scope = if where.nil? for_batch_indexing else for_batch_indexing.where(where) end records_in_scope.update_index_in_batches(batch_size: batch_size, index: index, type: type) end |
#update_index_in_parallel(parallelism:, index: nil, type: nil, min: nil, max: nil, batch_size: DEFAULT_BATCH_SIZE) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/elasticsearch/model/extensions/batch_updating.rb', line 35 def update_index_in_parallel(parallelism:, index: nil, type: nil, min: nil, max: nil, batch_size:DEFAULT_BATCH_SIZE) klass = self Parallel.each(__batch_updater__.split_ids_into(parallelism, min: min, max: max), in_processes: parallelism) do |id_range| __batch_updater__.reconnect! klass.for_indexing.update_index_for_ids_in_range id_range, index: index, type: type, batch_size: batch_size end klass.connection.reconnect! end |