<commit_before>module Elasticsearch
  module Model
    module Extensions
      module BatchUpdating
        class BatchUpdater
          def initialize(klass)
            @klass = klass
          end

          def klass
            @klass
          end

          def reconnect!
            klass.connection.reconnect!
            # This is required to prevent requests from timing out when they are made in multiple processes(in other words, the process is forked).
            klass.__elasticsearch__.client.transport.reload_connections!
          end

          # @param [Array] records
          def update_index_in_batch(records, index: nil, type: nil, client: nil)
            client ||= klass.__elasticsearch__.client
            index ||= klass.index_name
            type ||= klass.document_type
<commit_msg>Fix the problem in `BatchUpdater#reconnect!` which was causing the parallel indexing to time out<commit_after>module Elasticsearch
  module Model
    module Extensions
      module BatchUpdating
        class BatchUpdater
          def initialize(klass)
            @klass = klass
          end

          def klass
            @klass
          end

          def reconnect!
            klass.connection.reconnect!
            # This is required to prevent requests from timing out when they are made in multiple processes(in other words, the process is forked).
            klass.__elasticsearch__.client.transport.__build_connections
          end

          # @param [Array] records
          def update_index_in_batch(records, index: nil, type: nil, client: nil)
            client ||= klass.__elasticsearch__.client
            index ||= klass.index_name
            type ||= klass.document_type

{'fraction_non_alphanumeric': 0.0564281559045957, 'fraction_numerical': 0.0, 'mean_word_length': 2.006993006993007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2496961', 'n_tokens_mistral': 406, 'n_tokens_neox': 425, 'n_words': 139}