Module: Elasticsearch::Model::Adapter::ActiveRecord::Importing
- Defined in:
- lib/elasticsearch/model/adapters/active_record.rb
Instance Method Summary collapse
-
#__find_in_batches(options = {}, &block) ⇒ Object
Fetch batches of records from the database (used by the import method).
- #__transform ⇒ Object
Instance Method Details
#__find_in_batches(options = {}, &block) ⇒ Object
Fetch batches of records from the database (used by the import method)
86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/elasticsearch/model/adapters/active_record.rb', line 86 def __find_in_batches(={}, &block) query = .delete(:query) named_scope = .delete(:scope) preprocess = .delete(:preprocess) scope = self scope = scope.__send__(named_scope) if named_scope scope = scope.instance_exec(&query) if query scope.find_in_batches() do |batch| yield (preprocess ? self.__send__(preprocess, batch) : batch) end end |
#__transform ⇒ Object
100 101 102 |
# File 'lib/elasticsearch/model/adapters/active_record.rb', line 100 def __transform lambda { |model| { index: { _id: model.id, data: model.__elasticsearch__.as_indexed_json } } } end |