From aa38a1b5aa770cb1fa04487ba7a6d6511283155b Mon Sep 17 00:00:00 2001
From: Sylvain Bernier <sylvain@demarque.com>
Date: Mon, 11 Jul 2022 10:03:20 -0400
Subject: [PATCH] Add batch_size(batch_size) to __find_in_batches (Mongoid)

---
 elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb b/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb
index 850ea50e..e7eddf72 100644
--- a/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb
+++ b/elasticsearch-model/lib/elasticsearch/model/adapters/mongoid.rb
@@ -89,7 +89,7 @@ def __find_in_batches(options={}, &block)
             scope = all
             scope = scope.send(named_scope) if named_scope
             scope = query.is_a?(Proc) ? scope.class_exec(&query) : scope.where(query) if query
-            scope.no_timeout.each_slice(batch_size) do |items|
+            scope.no_timeout.batch_size(batch_size).each_slice(batch_size) do |items|
               yield (preprocess ? self.__send__(preprocess, items) : items)
             end
           end