Class: Elastics::Indices

Inherits:
Hash
  • Object
show all
Extended by:
Struct::Mergeable
Defined in:
lib/elastics/indices.rb

Instance Method Summary collapse

Methods included from Struct::Mergeable

deep_dup, deep_merge, deep_merge!

Constructor Details

#initialize(config_path) ⇒ Indices



6
7
8
9
# File 'lib/elastics/indices.rb', line 6

def initialize(config_path)
  hash = YAML.load(Utils.erb_process(config_path))
  replace Utils.delete_allcaps_keys(hash)
end

Instance Method Details

#create_index(index, name = nil, opts = {}) ⇒ Object



11
12
13
14
# File 'lib/elastics/indices.rb', line 11

def create_index(index, name=nil, opts={})
  name ||= index
  Elastics.PUT name, self[index], opts
end

#create_indices(indices = keys, opts = {}) ⇒ Object



16
17
18
# File 'lib/elastics/indices.rb', line 16

def create_indices(indices=keys, opts={})
  indices.each{|i| create_index(i, i, opts)}
end

#delete_indices(indices = keys, opts = {}) ⇒ Object



20
21
22
23
24
25
# File 'lib/elastics/indices.rb', line 20

def delete_indices(indices=keys, opts={})
  indices.each do |i|
    args = {:index=>i}.merge(opts)
    Elastics.delete_index(args)
  end
end