Module: ElasticSearch

Defined in:
lib/elasticsearch.rb,
lib/elasticsearch/version.rb

Defined Under Namespace

Classes: Error, Index, JSONResponse

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


30
31
32
33
34
# File 'lib/elasticsearch.rb', line 30

def self.available?
  conn = get_connection
  resp = conn.get '/'
  resp.status == 200
end

.get_connection(server) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/elasticsearch.rb', line 17

def self.get_connection(server)
  return unless server

  Faraday.new(:url => server) do |builder|
    # TODO: add timeout middleware
    builder.request  :json
    # builder.response :logger
    builder.response :json, :content_type => /\bjson$/

    builder.adapter :excon
  end
end