Module: ICFS::Elastic

Included in:
CacheElastic
Defined in:
lib/icfs/elastic.rb

Overview

Shared Elasticsearch methods

Instance Method Summary collapse

Instance Method Details

#create(maps) ⇒ Object

Create ES indices

Parameters:

  • maps (Hash)

    symbol to Elasticsearch mapping



68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/icfs/elastic.rb', line 68

def create(maps)
  head = {'Content-Type' => 'application/json'}.freeze
  maps.each do |ix, map|
    url = @map[ix]
    resp = @es.run_request(:put, url, map, head)
    if !resp.success?
      puts 'URL: %s' % url
      puts map
      puts resp.body
      raise('Elasticsearch index create failed: %s' % ix.to_s)
    end
  end
end