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
#cancel_tasks(options = {}) ⇒ Object
125
126
127
|
# File 'lib/meilisearch/client.rb', line 125
def cancel_tasks(options = {})
task_endpoint.cancel_tasks(options)
end
|
#create_dump ⇒ Object
119
120
121
|
# File 'lib/meilisearch/client.rb', line 119
def create_dump
http_post '/dumps'
end
|
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primaryKey: ‘id’)
34
35
36
37
38
|
# File 'lib/meilisearch/client.rb', line 34
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.
42
43
44
45
|
# File 'lib/meilisearch/client.rb', line 42
def create_index!(index_uid, options = {})
task = create_index(index_uid, options)
wait_for_task(task['taskUid'])
end
|
#create_key(key_options) ⇒ Object
77
78
79
80
81
|
# File 'lib/meilisearch/client.rb', line 77
def create_key(key_options)
body = Utils.transform_attributes(key_options)
http_post '/keys', body
end
|
#delete_index(index_uid) ⇒ Object
47
48
49
|
# File 'lib/meilisearch/client.rb', line 47
def delete_index(index_uid)
index_object(index_uid).delete
end
|
#delete_key(uid_or_key) ⇒ Object
90
91
92
|
# File 'lib/meilisearch/client.rb', line 90
def delete_key(uid_or_key)
http_delete "/keys/#{uid_or_key}"
end
|
#delete_tasks(options = {}) ⇒ Object
129
130
131
|
# File 'lib/meilisearch/client.rb', line 129
def delete_tasks(options = {})
task_endpoint.delete_tasks(options)
end
|
#fetch_index(index_uid) ⇒ Object
57
58
59
|
# File 'lib/meilisearch/client.rb', line 57
def fetch_index(index_uid)
index_object(index_uid).fetch_info
end
|
#fetch_raw_index(index_uid) ⇒ Object
61
62
63
|
# File 'lib/meilisearch/client.rb', line 61
def fetch_raw_index(index_uid)
index_object(index_uid).fetch_raw_info
end
|
#health ⇒ Object
103
104
105
|
# File 'lib/meilisearch/client.rb', line 103
def health
http_get '/health'
end
|
#healthy? ⇒ Boolean
96
97
98
99
100
101
|
# File 'lib/meilisearch/client.rb', line 96
def healthy?
http_get '/health'
true
rescue StandardError
false
end
|
#index(index_uid) ⇒ Object
Usage: client.index(‘indexUID’)
53
54
55
|
# File 'lib/meilisearch/client.rb', line 53
def index(index_uid)
index_object(index_uid)
end
|
#indexes(options = {}) ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'lib/meilisearch/client.rb', line 21
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
73
74
75
|
# File 'lib/meilisearch/client.rb', line 73
def key(uid_or_key)
http_get "/keys/#{uid_or_key}"
end
|
#keys(limit: nil, offset: nil) ⇒ Object
67
68
69
70
71
|
# File 'lib/meilisearch/client.rb', line 67
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
113
114
115
|
# File 'lib/meilisearch/client.rb', line 113
def stats
http_get '/stats'
end
|
#swap_indexes(*options) ⇒ Object
15
16
17
18
19
|
# File 'lib/meilisearch/client.rb', line 15
def swap_indexes(*options)
mapped_array = options.map { |arr| { indexes: arr } }
http_post '/swap-indexes', mapped_array
end
|
#task(task_uid) ⇒ Object
137
138
139
|
# File 'lib/meilisearch/client.rb', line 137
def task(task_uid)
task_endpoint.task(task_uid)
end
|
#tasks(options = {}) ⇒ Object
133
134
135
|
# File 'lib/meilisearch/client.rb', line 133
def tasks(options = {})
task_endpoint.task_list(options)
end
|
#update_key(uid_or_key, key_options) ⇒ Object
83
84
85
86
87
88
|
# File 'lib/meilisearch/client.rb', line 83
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
109
110
111
|
# File 'lib/meilisearch/client.rb', line 109
def version
http_get '/version'
end
|
#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object
141
142
143
|
# File 'lib/meilisearch/client.rb', line 141
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
|