Class: MeiliSearch::Client
Constant Summary
Constants included
from TenantToken
TenantToken::HEADER
Constants inherited
from HTTPRequest
HTTPRequest::DEFAULT_OPTIONS
Instance Attribute Summary
Attributes inherited from HTTPRequest
#headers, #options
Instance Method Summary
collapse
#generate_tenant_token
Methods inherited from HTTPRequest
#http_delete, #http_get, #http_patch, #http_post, #http_put, #initialize
Instance Method Details
#create_dump ⇒ Object
104
105
106
|
# File 'lib/meilisearch/client.rb', line 104
def create_dump
http_post '/dumps'
end
|
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primaryKey: ‘id’)
22
23
24
25
26
|
# File 'lib/meilisearch/client.rb', line 22
def create_index(index_uid, options = {})
body = Utils.transform_attributes(options.merge(uid: index_uid))
http_post '/indexes', body
end
|
#create_index!(index_uid, options = {}) ⇒ Object
Synchronous version of create_index. Waits for the task to be achieved, be careful when using it.
30
31
32
33
|
# File 'lib/meilisearch/client.rb', line 30
def create_index!(index_uid, options = {})
task = create_index(index_uid, options)
wait_for_task(task['uid'])
end
|
#create_key(key_options) ⇒ Object
63
64
65
66
67
|
# File 'lib/meilisearch/client.rb', line 63
def create_key(key_options)
body = Utils.transform_attributes(key_options)
http_post '/keys', body
end
|
#delete_index(index_uid) ⇒ Object
35
36
37
|
# File 'lib/meilisearch/client.rb', line 35
def delete_index(index_uid)
index_object(index_uid).delete
end
|
#delete_key(key_uid) ⇒ Object
75
76
77
|
# File 'lib/meilisearch/client.rb', line 75
def delete_key(key_uid)
http_delete "/keys/#{key_uid}"
end
|
#dump_status(dump_uid) ⇒ Object
Also known as:
get_dump_status
108
109
110
|
# File 'lib/meilisearch/client.rb', line 108
def dump_status(dump_uid)
http_get "/dumps/#{dump_uid}/status"
end
|
#fetch_index(index_uid) ⇒ Object
45
46
47
|
# File 'lib/meilisearch/client.rb', line 45
def fetch_index(index_uid)
index_object(index_uid).fetch_info
end
|
#fetch_raw_index(index_uid) ⇒ Object
49
50
51
|
# File 'lib/meilisearch/client.rb', line 49
def fetch_raw_index(index_uid)
index_object(index_uid).fetch_raw_info
end
|
#health ⇒ Object
88
89
90
|
# File 'lib/meilisearch/client.rb', line 88
def health
http_get '/health'
end
|
#healthy? ⇒ Boolean
81
82
83
84
85
86
|
# File 'lib/meilisearch/client.rb', line 81
def healthy?
http_get '/health'
true
rescue StandardError
false
end
|
#index(index_uid) ⇒ Object
Usage: client.index(‘indexUID’)
41
42
43
|
# File 'lib/meilisearch/client.rb', line 41
def index(index_uid)
index_object(index_uid)
end
|
#indexes ⇒ Object
13
14
15
16
17
|
# File 'lib/meilisearch/client.rb', line 13
def indexes
raw_indexes.map do |index_hash|
index_object(index_hash['uid'], index_hash['primaryKey'])
end
end
|
#key(key_uid) ⇒ Object
59
60
61
|
# File 'lib/meilisearch/client.rb', line 59
def key(key_uid)
http_get "/keys/#{key_uid}"
end
|
#keys ⇒ Object
55
56
57
|
# File 'lib/meilisearch/client.rb', line 55
def keys
http_get '/keys'
end
|
#raw_indexes ⇒ Object
9
10
11
|
# File 'lib/meilisearch/client.rb', line 9
def raw_indexes
http_get('/indexes')
end
|
#stats ⇒ Object
98
99
100
|
# File 'lib/meilisearch/client.rb', line 98
def stats
http_get '/stats'
end
|
#task(task_uid) ⇒ Object
119
120
121
|
# File 'lib/meilisearch/client.rb', line 119
def task(task_uid)
task_endpoint.task(task_uid)
end
|
#tasks ⇒ Object
115
116
117
|
# File 'lib/meilisearch/client.rb', line 115
def tasks
task_endpoint.task_list
end
|
#update_key(key_uid, key_options) ⇒ Object
69
70
71
72
73
|
# File 'lib/meilisearch/client.rb', line 69
def update_key(key_uid, key_options)
body = Utils.transform_attributes(key_options)
http_patch "/keys/#{key_uid}", body
end
|
#version ⇒ Object
94
95
96
|
# File 'lib/meilisearch/client.rb', line 94
def version
http_get '/version'
end
|
#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object
123
124
125
|
# File 'lib/meilisearch/client.rb', line 123
def wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50)
task_endpoint.wait_for_task(task_uid, timeout_in_ms, interval_in_ms)
end
|