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
113
114
115
|
# File 'lib/meilisearch/client.rb', line 113
def create_dump
http_post '/dumps'
end
|
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primaryKey: ‘id’)
28
29
30
31
32
|
# File 'lib/meilisearch/client.rb', line 28
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.
36
37
38
39
|
# File 'lib/meilisearch/client.rb', line 36
def create_index!(index_uid, options = {})
task = create_index(index_uid, options)
wait_for_task(task['taskUid'])
end
|
#create_key(key_options) ⇒ Object
71
72
73
74
75
|
# File 'lib/meilisearch/client.rb', line 71
def create_key(key_options)
body = Utils.transform_attributes(key_options)
http_post '/keys', body
end
|
#delete_index(index_uid) ⇒ Object
41
42
43
|
# File 'lib/meilisearch/client.rb', line 41
def delete_index(index_uid)
index_object(index_uid).delete
end
|
#delete_key(uid_or_key) ⇒ Object
84
85
86
|
# File 'lib/meilisearch/client.rb', line 84
def delete_key(uid_or_key)
http_delete "/keys/#{uid_or_key}"
end
|
#fetch_index(index_uid) ⇒ Object
51
52
53
|
# File 'lib/meilisearch/client.rb', line 51
def fetch_index(index_uid)
index_object(index_uid).fetch_info
end
|
#fetch_raw_index(index_uid) ⇒ Object
55
56
57
|
# File 'lib/meilisearch/client.rb', line 55
def fetch_raw_index(index_uid)
index_object(index_uid).fetch_raw_info
end
|
#health ⇒ Object
97
98
99
|
# File 'lib/meilisearch/client.rb', line 97
def health
http_get '/health'
end
|
#healthy? ⇒ Boolean
90
91
92
93
94
95
|
# File 'lib/meilisearch/client.rb', line 90
def healthy?
http_get '/health'
true
rescue StandardError
false
end
|
#index(index_uid) ⇒ Object
Usage: client.index(‘indexUID’)
47
48
49
|
# File 'lib/meilisearch/client.rb', line 47
def index(index_uid)
index_object(index_uid)
end
|
#indexes(options = {}) ⇒ Object
15
16
17
18
19
20
21
22
23
|
# File 'lib/meilisearch/client.rb', line 15
def indexes(options = {})
response = raw_indexes(options)
response['results'].map! do |index_hash|
index_object(index_hash['uid'], index_hash['primaryKey'])
end
response
end
|
#key(uid_or_key) ⇒ Object
67
68
69
|
# File 'lib/meilisearch/client.rb', line 67
def key(uid_or_key)
http_get "/keys/#{uid_or_key}"
end
|
#keys(limit: nil, offset: nil) ⇒ Object
61
62
63
64
65
|
# File 'lib/meilisearch/client.rb', line 61
def keys(limit: nil, offset: nil)
body = { limit: limit, offset: offset }.compact
http_get '/keys', body
end
|
#raw_indexes(options = {}) ⇒ Object
9
10
11
12
13
|
# File 'lib/meilisearch/client.rb', line 9
def raw_indexes(options = {})
body = Utils.transform_attributes(options.transform_keys(&:to_sym).slice(:limit, :offset))
http_get('/indexes', body)
end
|
#stats ⇒ Object
107
108
109
|
# File 'lib/meilisearch/client.rb', line 107
def stats
http_get '/stats'
end
|
#task(task_uid) ⇒ Object
123
124
125
|
# File 'lib/meilisearch/client.rb', line 123
def task(task_uid)
task_endpoint.task(task_uid)
end
|
#tasks(options = {}) ⇒ Object
119
120
121
|
# File 'lib/meilisearch/client.rb', line 119
def tasks(options = {})
task_endpoint.task_list(options)
end
|
#update_key(uid_or_key, key_options) ⇒ Object
77
78
79
80
81
82
|
# File 'lib/meilisearch/client.rb', line 77
def update_key(uid_or_key, key_options)
body = Utils.transform_attributes(key_options)
body = body.slice('description', 'name')
http_patch "/keys/#{uid_or_key}", body
end
|
#version ⇒ Object
103
104
105
|
# File 'lib/meilisearch/client.rb', line 103
def version
http_get '/version'
end
|
#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object
127
128
129
|
# File 'lib/meilisearch/client.rb', line 127
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
|