Class: MeiliSearch::Client

Inherits:
HTTPRequest show all
Defined in:
lib/meilisearch/client.rb

Instance Method Summary collapse

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, options = {})
  body = options.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, options = {})
  begin
    create_index(index_uid, options)
  rescue ApiError => e
    raise e unless e.code == 'index_already_exists'
  end
  index_object(index_uid)
end

#healthObject



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

#indexesObject

INDEXES



9
10
11
# File 'lib/meilisearch/client.rb', line 9

def indexes
  http_get '/indexes'
end

#keysObject 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

#statsObject



72
73
74
# File 'lib/meilisearch/client.rb', line 72

def stats
  http_get '/stats'
end

#versionObject

STATS



68
69
70
# File 'lib/meilisearch/client.rb', line 68

def version
  http_get '/version'
end