Class: RestClient

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

Instance Method Summary collapse

Constructor Details

#initialize(host: '127.0.0.1', port: 9200) ⇒ RestClient

Returns a new instance of RestClient.



3
4
5
# File 'lib/rest_client.rb', line 3

def initialize host: '127.0.0.1', port: 9200
  @client = Elasticsearch::Client.new(host: host, port: port)
end

Instance Method Details

#bulk(*args) ⇒ Object



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

def bulk *args
  return @client.bulk(*args)
end

#create(*args) ⇒ Object



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

def create *args
  return @client.create(*args)
end

#delete(*args) ⇒ Object



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

def delete *args
  return @client.delete(*args)
end

#delete_by_query(*args) ⇒ Object



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

def delete_by_query *args
  args.first[:body] = SearchSourceBuilder.new.query(args.first[:body]).body
  return @client.delete_by_query(*args)
end

#get(*args) ⇒ Object



36
37
38
# File 'lib/rest_client.rb', line 36

def get *args
  return @client.get(*args)
end

#index(*args) ⇒ Object



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

def index *args
  return @client.index(*args)
end

#mget(*args) ⇒ Object



40
41
42
# File 'lib/rest_client.rb', line 40

def mget *args
  return @client.mget(*args)
end

#msearch(msearch_request) ⇒ Object



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

def msearch msearch_request
  return @client.msearch(body: msearch_request.body)
end

#search(search_request) ⇒ Object



7
8
9
# File 'lib/rest_client.rb', line 7

def search search_request
  return @client.search(index: search_request.attributes.index, body: search_request.body)
end

#update(*args) ⇒ Object



44
45
46
# File 'lib/rest_client.rb', line 44

def update *args
  return @client.update(*args)
end

#update_by_query(*args) ⇒ Object



48
49
50
51
# File 'lib/rest_client.rb', line 48

def update_by_query *args
  args.first[:body] = SearchSourceBuilder.new.query(args.first[:body]).body
  return @client.update_by_query(*args)
end