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(requests, path = nil) ⇒ Object



39
40
41
# File 'lib/es/raw_client.rb', line 39

def bulk(requests, path = nil)
  @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

#get_mapping(path) ⇒ Object



43
44
45
# File 'lib/es/raw_client.rb', line 43

def get_mapping(path)
  @connection.request(:get, action_path(path, :mapping))
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

#scroll(params = {}) ⇒ Object



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

def scroll(params = {})
  @connection.request(:get, action_path(nil, 'search/scroll', params))
end

#search(path, query, params = {}) ⇒ Object



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

def search(path, query, params = {})
  @connection.request(:post, action_path(path, :search, params), query)
end

#update(path, data) ⇒ Object



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

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