Class: Blocktrain::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/blocktrain/client.rb

Class Method Summary collapse

Class Method Details

.endpointObject



12
13
14
# File 'lib/blocktrain/client.rb', line 12

def self.endpoint
  "#{url}/#{index}/_search"
end

.indexObject



20
21
22
# File 'lib/blocktrain/client.rb', line 20

def self.index
  ENV['ES_INDEX'] || 'train_data'
end

.results(query) ⇒ Object



4
5
6
7
8
9
10
# File 'lib/blocktrain/client.rb', line 4

def self.results query
  r = Curl::Easy.http_post(endpoint, query.to_json) do |c|
    c.ssl_verify_peer = false
  end

  JSON.parse r.body_str
end

.urlObject



16
17
18
# File 'lib/blocktrain/client.rb', line 16

def self.url
  ENV['ES_URL']
end