Class: MeiliSearch::Client
- Inherits:
-
HTTPRequest
- Object
- HTTPRequest
- MeiliSearch::Client
- Defined in:
- lib/meilisearch/client.rb
Instance Method Summary collapse
-
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primaryKey: ‘id’).
- #delete_index(index_uid) ⇒ Object
- #get_or_create_index(index_uid, options = {}) ⇒ Object
- #health ⇒ Object
-
#healthy? ⇒ Boolean
HEALTH.
-
#index(index_uid) ⇒ Object
(also: #get_index)
Usage: client.index(‘indexUID’).
-
#indexes ⇒ Object
INDEXES.
-
#keys ⇒ Object
(also: #get_keys)
KEYS.
- #show_index(index_uid) ⇒ Object
- #stats ⇒ Object
-
#version ⇒ Object
STATS.
Methods inherited from HTTPRequest
#http_delete, #http_get, #http_post, #http_put, #initialize
Constructor Details
This class inherits a constructor from MeiliSearch::HTTPRequest
Instance Method Details
#create_index(index_uid, options = {}) ⇒ Object
Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primaryKey: ‘id’)
20 21 22 23 24 |
# File 'lib/meilisearch/client.rb', line 20 def create_index(index_uid, = {}) body = .merge(uid: index_uid) res = http_post '/indexes', body index_object(res['uid']) 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 |
#get_or_create_index(index_uid, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/meilisearch/client.rb', line 26 def get_or_create_index(index_uid, = {}) begin create_index(index_uid, ) rescue ApiError => e raise e unless e.code == 'index_already_exists' end index_object(index_uid) end |
#health ⇒ Object
62 63 64 |
# File 'lib/meilisearch/client.rb', line 62 def health http_get '/health' end |
#healthy? ⇒ Boolean
HEALTH
55 56 57 58 59 60 |
# File 'lib/meilisearch/client.rb', line 55 def healthy? http_get '/health' true rescue StandardError false end |
#index(index_uid) ⇒ Object Also known as: get_index
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
INDEXES
9 10 11 |
# File 'lib/meilisearch/client.rb', line 9 def indexes http_get '/indexes' end |
#keys ⇒ Object Also known as: get_keys
KEYS
48 49 50 |
# File 'lib/meilisearch/client.rb', line 48 def keys http_get '/keys' end |
#show_index(index_uid) ⇒ Object
13 14 15 |
# File 'lib/meilisearch/client.rb', line 13 def show_index(index_uid) index_object(index_uid).show end |
#stats ⇒ Object
72 73 74 |
# File 'lib/meilisearch/client.rb', line 72 def stats http_get '/stats' end |
#version ⇒ Object
STATS
68 69 70 |
# File 'lib/meilisearch/client.rb', line 68 def version http_get '/version' end |