class Elasticsearch::Resources::Cluster

Public Class Methods

indexes() click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 71
def self.indexes
  (@index_names ||= {}).collect do |key, index_name|
    [key, Object.const_get(index_name)]
  end.to_h
end
new(&block) click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 10
def initialize(&block)
  configure(&block)
end

Protected Class Methods

define_indexes(indexes = {}) click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 79
def self.define_indexes(indexes = {})
  @index_names = indexes.collect do |key, index|
    [key.to_sym, index.class == Class ? index.name : index]
  end.to_h
end

Public Instance Methods

build_index(key:, index_class: nil) click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 32
def build_index(key:, index_class: nil)
  index_class = self.class.indexes[key] if index_class.nil?
  index_class&.new(cluster: self).tap do |index|
    settings.index(key).tap do |settings|
      index.settings = settings.dup unless settings.nil?
    end
  end
end
client() click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 19
def client
  settings.client
end
count(body, options = {}) click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 49
def count(body, options = {})
  params = {
    body: body
  }.merge(options)

  query(:count, params)
end
find_cluster() click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 57
def find_cluster
  self
end
find_index(index:) click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 61
def find_index(index:)
  indexes.values.find do |i|
    i.find_index(index: index)
  end
end
find_type(index:, type:) click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 67
def find_type(index:, type:)
  find_index(index: index)&.find_type(index: index, type: type)
end
indexes() click to toggle source
# File lib/elasticsearch/resources/cluster.rb, line 23
def indexes
  @indexes ||= self.class.indexes.collect do |key, index_class|
    [
      key,
      build_index(key: key)
    ]
  end.to_h
end
setup!() click to toggle source
Calls superclass method
# File lib/elasticsearch/resources/cluster.rb, line 14
def setup!
  client
  super
end