Class: ES::RawClient

Inherits:
Object
  • Object
show all
Defined in:
lib/es/raw_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ RawClient

Returns a new instance of RawClient.



3
4
5
6
7
8
9
# File 'lib/es/raw_client.rb', line 3

def initialize(opts = {})
  @connection = opts[:connection] || begin
    host = opts[:host] || 'http://localhost:9200'
    driver = opts[:driver] || Curl::Easy
    Connection.new(host, driver)
  end
end

Instance Method Details

#bulk(path, requests) ⇒ Object



35
36
37
# File 'lib/es/raw_client.rb', line 35

def bulk(path, requests)
  @connection.request(:post, action_path(path, :bulk), requests)
end

#create_index(name, definition) ⇒ Object



11
12
13
# File 'lib/es/raw_client.rb', line 11

def create_index(name, definition)
  @connection.request(:put, name, definition)
end

#delete_index(name) ⇒ Object



15
16
17
# File 'lib/es/raw_client.rb', line 15

def delete_index(name)
  @connection.request(:delete, name)
end

#get(path) ⇒ Object



19
20
21
# File 'lib/es/raw_client.rb', line 19

def get(path)
  @connection.request(:get, path)
end

#index(path, data) ⇒ Object



23
24
25
# File 'lib/es/raw_client.rb', line 23

def index(path, data)
  @connection.request(:put, path, data)
end

#search(path, query) ⇒ Object



27
28
29
# File 'lib/es/raw_client.rb', line 27

def search(path, query)
  @connection.request(:post, action_path(path, :search), query)
end

#update(path, data) ⇒ Object



31
32
33
# File 'lib/es/raw_client.rb', line 31

def update(path, data)
  @connection.request(:post, action_path(path, :update), data)
end