<commit_before>module ElasticRecord
  class Index
    module Settings
      def settings=(mapping)
        settings.deep_merge!(mapping)
      end

      def settings
        @settings ||=
          begin
            result = {}

            if (analysis = analysis_body).any?
              result['analysis'] = analysis
            end

            result
          end
      end

      def update_settings(index_name = alias_name)
        connection.json_put "/#{index_name}/_settings", settings
      end

      def analysis_body
        doctypes.each_with_object({}) do |doctype, result|
          result.deep_merge!(doctype.analysis)
        end
      end
    end
  end
end<commit_msg>Allow settings to update to be passed in (#74)<commit_after>module ElasticRecord
  class Index
    module Settings
      def settings=(mapping)
        settings.deep_merge!(mapping)
      end

      def settings
        @settings ||=
          begin
            result = {}

            if (analysis = analysis_body).any?
              result['analysis'] = analysis
            end

            result
          end
      end

      def update_settings(index_name = alias_name, settings: self.settings)
        connection.json_put "/#{index_name}/_settings", settings
      end

      def analysis_body
        doctypes.each_with_object({}) do |doctype, result|
          result.deep_merge!(doctype.analysis)
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07649513212795549, 'fraction_numerical': 0.0013908205841446453, 'mean_word_length': 1.777992277992278, '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': '2998551', 'n_tokens_mistral': 389, 'n_tokens_neox': 375, 'n_words': 95}