<commit_before>require 'elsearch-node'
require 'jruby'

Dir["#{ElasticSearch::Node.lib}/*.jar"].each do |jar|
  require jar
end

module ElasticSearch
  module Node
    class Embedded
      include ElasticSearch::ClientProvider
      
      def initialize(opts = {})
        cluster_name = opts[:cluster_name] || "default"
        settings = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder.put("cluster.name", cluster_name).put("gateway.type", "none").put("number_of_shards", 1)
        
        @node ||= org.elasticsearch.node.NodeBuilder.nodeBuilder.settings(settings).local(true).node
        super(opts)
      end

      def port
        Integer(socket_address.port)
      end

      def ip<commit_msg>Better settings handling for embedded nodes<commit_after>require 'elsearch-node'
require 'jruby'

Dir["#{ElasticSearch::Node.lib}/*.jar"].each do |jar|
  require jar
end

module ElasticSearch
  module Node
    class Embedded
      include ElasticSearch::ClientProvider
      include 
      def initialize(opts = {})
        node_builder = org.elasticsearch.node.NodeBuilder.nodeBuilder.loadConfigSettings(true)
        settings_builder = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder
        
        if opts[:config]
          settings_builder.put("path.home", opts[:config])
        end
        
        settings_builder.put(opts[:settings]) if opts[:settings]
        #pry opts[:settings]
        #cluster_name = opts[:cluster_name] || "default"
        #settings = org.elasticsearch.common.settings.ImmutableSettings.settingsBuilder.put("cluster.name", cluster_name)#.put("gateway.type", "none").put("number_of_shards", 1)#.put("http.type", "FooBarClazz")

        @node ||= node_builder.settings(settings_builder).node
        super(opts)
      end

      def port
        Integer(socket_address.port)
      end

      def ip
{'fraction_non_alphanumeric': 0.11714589989350373, 'fraction_numerical': 0.0010649627263045794, 'mean_word_length': 3.251131221719457, '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': '3472974', 'n_tokens_mistral': 543, 'n_tokens_neox': 537, 'n_words': 96}