meilisearch 0.14.0 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a1861bef27e914a71fc706d4b0758a585842cc33421fa8a7ecacb0a45f146903
4
- data.tar.gz: 33b66d0151cc205fd7d964b78608cd5f6641f2d9740d3b28d3fd2f52ee36d98c
3
+ metadata.gz: e60c9c4ac5631947edf24d990c37fd06e09bbbb59b6eabd554fcacc7d8f231ed
4
+ data.tar.gz: 5373d86aacf0791fa30f068d97ba9f5b857fa75930c3580ddd20449cd2db8e7b
5
5
  SHA512:
6
- metadata.gz: 7600f98e465ddf28304b52f5ee12c199d7f6486b2230b2e1bea3d988bc41b3936875fbbf6f5a03ee5a6ac416d40e5dcddd8abc906415b6be44f67ba52c79a56d
7
- data.tar.gz: d3e8eecfdd30d26a7bbb2dac5c7e216406093782015d232765315897a24744c02e2fac8113c169e4dfc7f5bd2cbe2cdbd3042c5fcb1aaab3e1d5212626b485ee
6
+ metadata.gz: d7496a3f2ea08ed35ff277c0176c52fe8120290678a1594bd49637e96b03e825aad11bfd55370040fd3563577fea9fbc6a3a7df335bb400a78d2a46707072ff2
7
+ data.tar.gz: db46abc6f60ec202641480eb0ac2232b2892ea966590d955735f4ab7a5ce98cc52493c87da7bb1ccc5d4399f95b0b4c7639619ad0a30ed4caa4f21e3af7aabf3
@@ -10,26 +10,24 @@ module MeiliSearch
10
10
  http_get '/indexes'
11
11
  end
12
12
 
13
- def show_index(index_uid)
14
- index_object(index_uid).show
15
- end
16
-
17
13
  # Usage:
18
14
  # client.create_index('indexUID')
19
15
  # client.create_index('indexUID', primaryKey: 'id')
20
16
  def create_index(index_uid, options = {})
21
17
  body = options.merge(uid: index_uid)
22
- res = http_post '/indexes', body
23
- index_object(res['uid'])
18
+ index_hash = http_post '/indexes', body
19
+ index_object(index_hash['uid'], index_hash['primaryKey'])
24
20
  end
25
21
 
26
22
  def get_or_create_index(index_uid, options = {})
27
23
  begin
28
- create_index(index_uid, options)
24
+ index_instance = fetch_index(index_uid)
29
25
  rescue ApiError => e
30
- raise e unless e.code == 'index_already_exists'
26
+ raise e unless e.code == 'index_not_found'
27
+
28
+ index_instance = create_index(index_uid, options)
31
29
  end
32
- index_object(index_uid)
30
+ index_instance
33
31
  end
34
32
 
35
33
  def delete_index(index_uid)
@@ -41,7 +39,10 @@ module MeiliSearch
41
39
  def index(index_uid)
42
40
  index_object(index_uid)
43
41
  end
44
- alias get_index index
42
+
43
+ def fetch_index(index_uid)
44
+ index_object(index_uid).fetch_info
45
+ end
45
46
 
46
47
  ### KEYS
47
48
 
@@ -73,10 +74,21 @@ module MeiliSearch
73
74
  http_get '/stats'
74
75
  end
75
76
 
77
+ ### DUMPS
78
+
79
+ def create_dump
80
+ http_post '/dumps'
81
+ end
82
+
83
+ def dump_status(dump_uid)
84
+ http_get "/dumps/#{dump_uid}/status"
85
+ end
86
+ alias get_dump_status dump_status
87
+
76
88
  private
77
89
 
78
- def index_object(uid)
79
- Index.new(uid, @base_url, @api_key)
90
+ def index_object(uid, primary_key = nil)
91
+ Index.new(uid, @base_url, @api_key, primary_key)
80
92
  end
81
93
  end
82
94
  end
@@ -5,20 +5,24 @@ require 'timeout'
5
5
 
6
6
  module MeiliSearch
7
7
  class Index < HTTPRequest
8
- attr_reader :uid
8
+ attr_reader :uid, :primary_key
9
9
 
10
- def initialize(index_uid, url, api_key = nil)
10
+ def initialize(index_uid, url, api_key = nil, primary_key = nil)
11
11
  @uid = index_uid
12
+ @primary_key = primary_key
12
13
  super(url, api_key)
13
14
  end
14
15
 
15
- def show
16
- http_get "/indexes/#{@uid}"
16
+ def fetch_info
17
+ index_hash = http_get "/indexes/#{@uid}"
18
+ @primary_key = index_hash['primaryKey']
19
+ self
17
20
  end
18
- alias show_index show
19
21
 
20
22
  def update(body)
21
- http_put "/indexes/#{@uid}", body
23
+ index_hash = http_put "/indexes/#{@uid}", body
24
+ @primary_key = index_hash['primaryKey']
25
+ self
22
26
  end
23
27
  alias update_index update
24
28
 
@@ -27,10 +31,10 @@ module MeiliSearch
27
31
  end
28
32
  alias delete_index delete
29
33
 
30
- def primary_key
31
- show['primaryKey']
34
+ def fetch_primary_key
35
+ fetch_info.primary_key
32
36
  end
33
- alias get_primary_key primary_key
37
+ alias get_primary_key fetch_primary_key
34
38
 
35
39
  ### DOCUMENTS
36
40
 
@@ -140,6 +144,7 @@ module MeiliSearch
140
144
  def update_settings(settings)
141
145
  http_post "/indexes/#{@uid}/settings", settings
142
146
  end
147
+ alias settings= update_settings
143
148
 
144
149
  def reset_settings
145
150
  http_delete "/indexes/#{@uid}/settings"
@@ -155,6 +160,7 @@ module MeiliSearch
155
160
  def update_ranking_rules(ranking_rules)
156
161
  http_post "/indexes/#{@uid}/settings/ranking-rules", ranking_rules
157
162
  end
163
+ alias ranking_rules= update_ranking_rules
158
164
 
159
165
  def reset_ranking_rules
160
166
  http_delete "/indexes/#{@uid}/settings/ranking-rules"
@@ -170,6 +176,7 @@ module MeiliSearch
170
176
  def update_synonyms(synonyms)
171
177
  http_post "/indexes/#{@uid}/settings/synonyms", synonyms
172
178
  end
179
+ alias synonyms= update_synonyms
173
180
 
174
181
  def reset_synonyms
175
182
  http_delete "/indexes/#{@uid}/settings/synonyms"
@@ -186,6 +193,7 @@ module MeiliSearch
186
193
  body = stop_words.is_a?(Array) ? stop_words : [stop_words]
187
194
  http_post "/indexes/#{@uid}/settings/stop-words", body
188
195
  end
196
+ alias stop_words= update_stop_words
189
197
 
190
198
  def reset_stop_words
191
199
  http_delete "/indexes/#{@uid}/settings/stop-words"
@@ -201,6 +209,7 @@ module MeiliSearch
201
209
  def update_distinct_attribute(distinct_attribute)
202
210
  http_post "/indexes/#{@uid}/settings/distinct-attribute", distinct_attribute
203
211
  end
212
+ alias distinct_attribute= update_distinct_attribute
204
213
 
205
214
  def reset_distinct_attribute
206
215
  http_delete "/indexes/#{@uid}/settings/distinct-attribute"
@@ -216,6 +225,7 @@ module MeiliSearch
216
225
  def update_searchable_attributes(searchable_attributes)
217
226
  http_post "/indexes/#{@uid}/settings/searchable-attributes", searchable_attributes
218
227
  end
228
+ alias searchable_attributes= update_searchable_attributes
219
229
 
220
230
  def reset_searchable_attributes
221
231
  http_delete "/indexes/#{@uid}/settings/searchable-attributes"
@@ -231,6 +241,7 @@ module MeiliSearch
231
241
  def update_displayed_attributes(displayed_attributes)
232
242
  http_post "/indexes/#{@uid}/settings/displayed-attributes", displayed_attributes
233
243
  end
244
+ alias displayed_attributes= update_displayed_attributes
234
245
 
235
246
  def reset_displayed_attributes
236
247
  http_delete "/indexes/#{@uid}/settings/displayed-attributes"
@@ -246,6 +257,7 @@ module MeiliSearch
246
257
  def update_attributes_for_faceting(attributes_for_faceting)
247
258
  http_post "/indexes/#{@uid}/settings/attributes-for-faceting", attributes_for_faceting
248
259
  end
260
+ alias attributes_for_faceting= update_attributes_for_faceting
249
261
 
250
262
  def reset_attributes_for_faceting
251
263
  http_delete "/indexes/#{@uid}/settings/attributes-for-faceting"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeiliSearch
4
- VERSION = '0.14.0'
4
+ VERSION = '0.15.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meilisearch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.0
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-04 00:00:00.000000000 Z
11
+ date: 2020-11-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty