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_dumpObject

DUMPS



79
80
81
# File 'lib/meilisearch/client.rb', line 79

def create_dump
  http_post '/dumps'
end

#create_index(index_uid, options = {}) ⇒ Object

Usage: client.create_index(‘indexUID’) client.create_index(‘indexUID’, primaryKey: ‘id’)



16
17
18
19
20
# File 'lib/meilisearch/client.rb', line 16

def create_index(index_uid, options = {})
  body = options.merge(uid: index_uid)
  index_hash = http_post '/indexes', body
  index_object(index_hash['uid'], index_hash['primaryKey'])
end

#delete_index(index_uid) ⇒ Object



33
34
35
# File 'lib/meilisearch/client.rb', line 33

def delete_index(index_uid)
  index_object(index_uid).delete
end

#dump_status(dump_uid) ⇒ Object Also known as: get_dump_status



83
84
85
# File 'lib/meilisearch/client.rb', line 83

def dump_status(dump_uid)
  http_get "/dumps/#{dump_uid}/status"
end

#fetch_index(index_uid) ⇒ Object



43
44
45
# File 'lib/meilisearch/client.rb', line 43

def fetch_index(index_uid)
  index_object(index_uid).fetch_info
end

#get_or_create_index(index_uid, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
# File 'lib/meilisearch/client.rb', line 22

def get_or_create_index(index_uid, options = {})
  begin
    index_instance = fetch_index(index_uid)
  rescue ApiError => e
    raise e unless e.code == 'index_not_found'

    index_instance = create_index(index_uid, options)
  end
  index_instance
end

#healthObject



63
64
65
# File 'lib/meilisearch/client.rb', line 63

def health
  http_get '/health'
end

#healthy?Boolean

HEALTH

Returns:

  • (Boolean)


56
57
58
59
60
61
# File 'lib/meilisearch/client.rb', line 56

def healthy?
  http_get '/health'
  true
rescue StandardError
  false
end

#index(index_uid) ⇒ Object

Usage: client.index(‘indexUID’)



39
40
41
# File 'lib/meilisearch/client.rb', line 39

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



49
50
51
# File 'lib/meilisearch/client.rb', line 49

def keys
  http_get '/keys'
end

#statsObject



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

def stats
  http_get '/stats'
end

#versionObject

STATS



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

def version
  http_get '/version'
end