def replace_all_objects(objects, request_options = {})
      safe = request_options[:safe] || request_options['safe'] || false
      request_options.delete(:safe)
      request_options.delete('safe')

      tmp_index = @client.init_index(@name + '_tmp_' + rand(10000000).to_s)

      responses = []

      scope = ['settings', 'synonyms', 'rules']
      res = @client.copy_index(@name, tmp_index.name, scope, request_options)
      responses << res

      if safe
        wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      end

      batch = []
      batch_size = 1000
      count = 0

      objects.each do |object|
        batch << object
        count += 1
        if count == batch_size
          res = tmp_index.add_objects(batch, request_options)
          responses << res
          batch = []
          count = 0
        end
      end

      if batch.any?
        res = tmp_index.add_objects(batch, request_options)
        responses << res
      end

      if safe
        responses.each do |res|
          tmp_index.wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
        end
      end

      res = @client.move_index(tmp_index.name, @name, request_options)
      responses << res

      if safe
        wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      end

      responses
    end
def replace_all_objects(objects, request_options = {})
      safe = request_options[:safe] || request_options['safe'] || false
      request_options.delete(:safe)
      request_options.delete('safe')

      tmp_index = @client.init_index(@name + '_tmp_' + rand(10000000).to_s)

      responses = []

      scope = ['settings', 'synonyms', 'rules']
      res = @client.copy_index(@name, tmp_index.name, scope, request_options)
      responses << res

      if safe
        wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      end

      batch = []
      batch_size = 1000
      count = 0

      objects.each do |object|
        batch << object
        count += 1
        if count == batch_size
          res = tmp_index.add_objects(batch, request_options)
          responses << res
          batch = []
          count = 0
        end
      end

      if batch.any?
        res = tmp_index.add_objects(batch, request_options)
        responses << res
      end

      if safe
        responses.each do |res|
          tmp_index.wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
        end
      end

      res = @client.move_index(tmp_index.name, @name, request_options)
      responses << res

      if safe
        wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)
      end

      responses
    end
Override the current objects by the given array of objects and wait end of indexing. Settings,
 synonyms and query rules are untouched. The objects are replaced without any downtime.

 @param objects the array of objects to save
 @param request_options contains extra parameters to send with your query