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
#multi_search
#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
132
133
134
|
# File 'lib/meilisearch/client.rb', line 132
def cancel_tasks(options = {})
task_endpoint.cancel_tasks(options)
end
|
#create_dump ⇒ Object
120
121
122
|
# File 'lib/meilisearch/client.rb', line 120
def create_dump
http_post '/dumps'
end
|
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primary_key: ‘id’)
35
36
37
38
39
|
# File 'lib/meilisearch/client.rb', line 35
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.
43
44
45
46
|
# File 'lib/meilisearch/client.rb', line 43
def create_index!(index_uid, options = {})
task = create_index(index_uid, options)
wait_for_task(task['taskUid'])
end
|
#create_key(key_options) ⇒ Object
78
79
80
81
82
|
# File 'lib/meilisearch/client.rb', line 78
def create_key(key_options)
body = Utils.transform_attributes(key_options)
http_post '/keys', body
end
|
#create_snapshot ⇒ Object
126
127
128
|
# File 'lib/meilisearch/client.rb', line 126
def create_snapshot
http_post '/snapshots'
end
|
#delete_index(index_uid) ⇒ Object
48
49
50
|
# File 'lib/meilisearch/client.rb', line 48
def delete_index(index_uid)
index_object(index_uid).delete
end
|
#delete_key(uid_or_key) ⇒ Object
91
92
93
|
# File 'lib/meilisearch/client.rb', line 91
def delete_key(uid_or_key)
http_delete "/keys/#{uid_or_key}"
end
|
#delete_tasks(options = {}) ⇒ Object
136
137
138
|
# File 'lib/meilisearch/client.rb', line 136
def delete_tasks(options = {})
task_endpoint.delete_tasks(options)
end
|
#fetch_index(index_uid) ⇒ Object
58
59
60
|
# File 'lib/meilisearch/client.rb', line 58
def fetch_index(index_uid)
index_object(index_uid).fetch_info
end
|
#fetch_raw_index(index_uid) ⇒ Object
62
63
64
|
# File 'lib/meilisearch/client.rb', line 62
def fetch_raw_index(index_uid)
index_object(index_uid).fetch_raw_info
end
|
#health ⇒ Object
104
105
106
|
# File 'lib/meilisearch/client.rb', line 104
def health
http_get '/health'
end
|
#healthy? ⇒ Boolean
97
98
99
100
101
102
|
# File 'lib/meilisearch/client.rb', line 97
def healthy?
http_get '/health'
true
rescue StandardError
false
end
|
#index(index_uid) ⇒ Object
Usage: client.index(‘indexUID’)
54
55
56
|
# File 'lib/meilisearch/client.rb', line 54
def index(index_uid)
index_object(index_uid)
end
|
#indexes(options = {}) ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'lib/meilisearch/client.rb', line 22
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
74
75
76
|
# File 'lib/meilisearch/client.rb', line 74
def key(uid_or_key)
http_get "/keys/#{uid_or_key}"
end
|
#keys(limit: nil, offset: nil) ⇒ Object
68
69
70
71
72
|
# File 'lib/meilisearch/client.rb', line 68
def keys(limit: nil, offset: nil)
body = { limit: limit, offset: offset }.compact
http_get '/keys', body
end
|
#raw_indexes(options = {}) ⇒ Object
10
11
12
13
14
|
# File 'lib/meilisearch/client.rb', line 10
def raw_indexes(options = {})
body = Utils.transform_attributes(options.transform_keys(&:to_sym).slice(:limit, :offset))
http_get('/indexes', body)
end
|
#stats ⇒ Object
114
115
116
|
# File 'lib/meilisearch/client.rb', line 114
def stats
http_get '/stats'
end
|
#swap_indexes(*options) ⇒ Object
16
17
18
19
20
|
# File 'lib/meilisearch/client.rb', line 16
def swap_indexes(*options)
mapped_array = options.map { |arr| { indexes: arr } }
http_post '/swap-indexes', mapped_array
end
|
#task(task_uid) ⇒ Object
144
145
146
|
# File 'lib/meilisearch/client.rb', line 144
def task(task_uid)
task_endpoint.task(task_uid)
end
|
#tasks(options = {}) ⇒ Object
140
141
142
|
# File 'lib/meilisearch/client.rb', line 140
def tasks(options = {})
task_endpoint.task_list(options)
end
|
#update_key(uid_or_key, key_options) ⇒ Object
84
85
86
87
88
89
|
# File 'lib/meilisearch/client.rb', line 84
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
110
111
112
|
# File 'lib/meilisearch/client.rb', line 110
def version
http_get '/version'
end
|
#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object
148
149
150
|
# File 'lib/meilisearch/client.rb', line 148
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
|