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
140
141
142
|
# File 'lib/meilisearch/client.rb', line 140
def cancel_tasks(options = {})
task_endpoint.cancel_tasks(options)
end
|
#create_dump ⇒ Object
127
128
129
130
|
# File 'lib/meilisearch/client.rb', line 127
def create_dump
response = http_post '/dumps'
Models::Task.new(response, task_endpoint)
end
|
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primary_key: ‘id’)
36
37
38
39
40
41
42
|
# File 'lib/meilisearch/client.rb', line 36
def create_index(index_uid, options = {})
body = Utils.transform_attributes(options.merge(uid: index_uid))
response = http_post '/indexes', body
Models::Task.new(response, task_endpoint)
end
|
#create_index!(index_uid, options = {}) ⇒ Object
Synchronous version of create_index. Waits for the task to be achieved, be careful when using it.
46
47
48
49
50
51
52
53
|
# File 'lib/meilisearch/client.rb', line 46
def create_index!(index_uid, options = {})
Utils.soft_deprecate(
'Client#create_index!',
"client.create_index('#{index_uid}').await"
)
create_index(index_uid, options).await
end
|
#create_key(key_options) ⇒ Object
85
86
87
88
89
|
# File 'lib/meilisearch/client.rb', line 85
def create_key(key_options)
body = Utils.transform_attributes(key_options)
http_post '/keys', body
end
|
#create_snapshot ⇒ Object
134
135
136
|
# File 'lib/meilisearch/client.rb', line 134
def create_snapshot
http_post '/snapshots'
end
|
#delete_index(index_uid) ⇒ Object
55
56
57
|
# File 'lib/meilisearch/client.rb', line 55
def delete_index(index_uid)
index_object(index_uid).delete
end
|
#delete_key(uid_or_key) ⇒ Object
98
99
100
|
# File 'lib/meilisearch/client.rb', line 98
def delete_key(uid_or_key)
http_delete "/keys/#{uid_or_key}"
end
|
#delete_tasks(options = {}) ⇒ Object
144
145
146
|
# File 'lib/meilisearch/client.rb', line 144
def delete_tasks(options = {})
task_endpoint.delete_tasks(options)
end
|
#fetch_index(index_uid) ⇒ Object
65
66
67
|
# File 'lib/meilisearch/client.rb', line 65
def fetch_index(index_uid)
index_object(index_uid).fetch_info
end
|
#fetch_raw_index(index_uid) ⇒ Object
69
70
71
|
# File 'lib/meilisearch/client.rb', line 69
def fetch_raw_index(index_uid)
index_object(index_uid).fetch_raw_info
end
|
#health ⇒ Object
111
112
113
|
# File 'lib/meilisearch/client.rb', line 111
def health
http_get '/health'
end
|
#healthy? ⇒ Boolean
104
105
106
107
108
109
|
# File 'lib/meilisearch/client.rb', line 104
def healthy?
http_get '/health'
true
rescue StandardError
false
end
|
#index(index_uid) ⇒ Object
Usage: client.index(‘indexUID’)
61
62
63
|
# File 'lib/meilisearch/client.rb', line 61
def index(index_uid)
index_object(index_uid)
end
|
#indexes(options = {}) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'lib/meilisearch/client.rb', line 23
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
81
82
83
|
# File 'lib/meilisearch/client.rb', line 81
def key(uid_or_key)
http_get "/keys/#{uid_or_key}"
end
|
#keys(limit: nil, offset: nil) ⇒ Object
75
76
77
78
79
|
# File 'lib/meilisearch/client.rb', line 75
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
121
122
123
|
# File 'lib/meilisearch/client.rb', line 121
def stats
http_get '/stats'
end
|
#swap_indexes(*options) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/meilisearch/client.rb', line 16
def swap_indexes(*options)
mapped_array = options.map { |arr| { indexes: arr } }
response = http_post '/swap-indexes', mapped_array
Models::Task.new(response, task_endpoint)
end
|
#task(task_uid) ⇒ Object
152
153
154
|
# File 'lib/meilisearch/client.rb', line 152
def task(task_uid)
task_endpoint.task(task_uid)
end
|
#tasks(options = {}) ⇒ Object
148
149
150
|
# File 'lib/meilisearch/client.rb', line 148
def tasks(options = {})
task_endpoint.task_list(options)
end
|
#update_key(uid_or_key, key_options) ⇒ Object
91
92
93
94
95
96
|
# File 'lib/meilisearch/client.rb', line 91
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
117
118
119
|
# File 'lib/meilisearch/client.rb', line 117
def version
http_get '/version'
end
|
#wait_for_task(task_uid, timeout_in_ms = 5000, interval_in_ms = 50) ⇒ Object
156
157
158
|
# File 'lib/meilisearch/client.rb', line 156
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
|