Class: Marqo::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ept = nil, name = nil) ⇒ Client

Returns a new instance of Client.



5
6
7
8
# File 'lib/marqo/client.rb', line 5

def initialize(ept = nil, name = nil)
  self.endpoint   = ept  || Marqo.configuration.endpoint
  self.index_name = name || Marqo.configuration.index_name
end

Instance Attribute Details

#endpointObject

Returns the value of attribute endpoint.



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

def endpoint
  @endpoint
end

#index_nameObject

Returns the value of attribute index_name.



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

def index_name
  @index_name
end

Instance Method Details

#add_documents(documents, options = {}) ⇒ Object



22
23
24
# File 'lib/marqo/client.rb', line 22

def add_documents(documents, options = {})
  Marqo::Document.create(endpoint, index_name, documents, options)
end

#create_index(index_name, options = {}) ⇒ Object



10
11
12
# File 'lib/marqo/client.rb', line 10

def create_index(index_name, options = {})
  Marqo::Index.create(endpoint, index_name, options)
end

#delete_docs(document_ids) ⇒ Object



34
35
36
# File 'lib/marqo/client.rb', line 34

def delete_docs(document_ids)
  Marqo::Document.delete(endpoint, index_name, document_ids)
end

#delete_indexObject



18
19
20
# File 'lib/marqo/client.rb', line 18

def delete_index
  Marqo::Index.delete(endpoint, index_name)
end

#device_cpuObject



42
43
44
# File 'lib/marqo/client.rb', line 42

def device_cpu
  Marqo::Device.cpu(endpoint)
end

#device_cudaObject



46
47
48
# File 'lib/marqo/client.rb', line 46

def device_cuda
  Marqo::Device.cuda(endpoint)
end

#find_doc(document_id, options = {}) ⇒ Object



26
27
28
# File 'lib/marqo/client.rb', line 26

def find_doc(document_id, options = {})
  Marqo::Document.find(endpoint, index_name, document_id, options)
end

#find_docs(document_ids) ⇒ Object



30
31
32
# File 'lib/marqo/client.rb', line 30

def find_docs(document_ids)
  Marqo::Document.finds(endpoint, index_name, document_ids)
end

#list_indexObject



14
15
16
# File 'lib/marqo/client.rb', line 14

def list_index
  Marqo::Index.list(endpoint)
end

#search(query, options = {}) ⇒ Object



38
39
40
# File 'lib/marqo/client.rb', line 38

def search(query, options = {})
  Marqo::Search.run(endpoint, index_name, query, options)
end