class Esse::Cluster

Constants

ATTRIBUTES

Attributes

id[R]
index_prefix[RW]

The index prefix. For example an index named UsersIndex. With `index_prefix = 'app1'`. Final index/alias is: 'app1_users'

index_settings[RW]

This settings will be passed through all indices during the mapping

Public Class Methods

new(id:, **options) click to toggle source
# File lib/esse/cluster.rb, line 16
def initialize(id:, **options)
  @id = id.to_sym
  @index_settings = {}
  assign(options)
end

Public Instance Methods

assign(hash) click to toggle source
# File lib/esse/cluster.rb, line 22
def assign(hash)
  return unless hash.is_a?(Hash)

  hash.each do |key, value|
    method = (ATTRIBUTES & [key.to_s, key.to_sym]).first
    next unless method

    public_send(:"#{method}=", value)
  end
end
client() click to toggle source
# File lib/esse/cluster.rb, line 33
def client
  @client ||= Elasticsearch::Client.new
end
client=(es_client) click to toggle source

Define the elasticsearch client connectio @param es_client [Elasticsearch::Client, Hash] an instance of elasticsearch/api client or an hash

with the settings that will be used to initialize Elasticsearch::Client
# File lib/esse/cluster.rb, line 40
def client=(es_client)
  @client = if es_client.is_a?(Hash)
    settings = es_client.each_with_object({}) { |(k,v), r| r[k.to_sym] = v }
    Elasticsearch::Client.new(settings)
  else
    es_client
  end
end
inspect() click to toggle source
# File lib/esse/cluster.rb, line 49
def inspect
  attrs = ([:id] + ATTRIBUTES - [:client]).map do |method|
    value = public_send(method)
    format('%<k>s=%<v>p', k: method, v: value) if value
  end.compact
  attrs << format('client=%p', @client)
  format('#<Esse::Cluster %<attrs>s>', attrs: attrs.join(' '))
end