lib/mongoid/elasticsearch/es.rb in mongoid-elasticsearch-0.4.1 vs lib/mongoid/elasticsearch/es.rb in mongoid-elasticsearch-0.4.2
- old
+ new
@@ -23,11 +23,15 @@
q = klass.order_by(_id: 1)
steps = (q.count / step_size) + 1
steps.times do |step|
docs = q.skip(step * step_size).limit(step_size)
docs = docs.map do |obj|
- { index: {data: obj.as_indexed_json}.merge(_id: obj.id.to_s) }
- end
+ if obj.es_index?
+ { index: {data: obj.as_indexed_json}.merge(_id: obj.id.to_s) }
+ else
+ nil
+ end
+ end.reject { |obj| obj.nil? }
client.bulk({body: docs}.merge(type_options))
if block_given?
yield steps, step
end
end