<commit_before>module Search
  class Client
    def self.request(method, path, options = {})
      unless path.start_with?("/")
        path = "/#{path}"
      end
      $elasticsearch[:pool].with do |connection|
        connection.headers(content_type: "application/json").request(method.to_sym, path, options).parse
      end
    end

    def self.index(index_name, id:, document:)
      Search::Client.request(:put, [index_name, "_doc", id].join("/"), json: document)
    end

    def self.delete(index_name, id:)
      Search::Client.request(:delete, [index_name, "_doc", id].join("/"))
    end

    def self.bulk(records)
      Search::Client.request(:post, "_bulk", body: prepare_bulk_request(records))
    end

    def self.validate(index_name, query:)
      result = Search::Client.request(:get, [index_name, "_validate", "query"].join("/"), json: query)<commit_msg>Ignore response for bulk<commit_after>module Search
  class Client
    def self.request(method, path, options = {})
      unless path.start_with?("/")
        path = "/#{path}"
      end
      $elasticsearch[:pool].with do |connection|
        connection.headers(content_type: "application/json").request(method.to_sym, path, options).parse
      end
    end

    def self.index(index_name, id:, document:)
      Search::Client.request(:put, [index_name, "_doc", id].join("/"), json: document)
    end

    def self.delete(index_name, id:)
      Search::Client.request(:delete, [index_name, "_doc", id].join("/"))
    end

    def self.bulk(records)
      options = {
        body: prepare_bulk_request(records),
        params: {"filter_path" => "took"}
      }
      Search::Client.request(:post, "_bulk", options)
    end

    def self.validate(index_name, query:)
      result = Search::Client.request(:get, [index_name, "_validate", "query"].join("/"), json: query)
{'fraction_non_alphanumeric': 0.1621475054229935, 'fraction_numerical': 0.0, 'mean_word_length': 3.3617021276595747, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '5419621', 'n_tokens_mistral': 568, 'n_tokens_neox': 557, 'n_words': 123}