meilisearch 0.15.2 → 0.16.1

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: f1a2bd63d9c8d081f0c4f9402f754fcd710b57a1e362aec937976b97bc2a7d32
4
- data.tar.gz: c438bda2666f88704c58b0ced8c55803211848bd7a26ccf0059db36b29a860b7
3
+ metadata.gz: 5c898ee113e0f0a16da0b80ab6b0a079021eaa8ead536da8dfe283b7613dc27a
4
+ data.tar.gz: 29eed6b1c4a3de9efbe54dd766718d70699c5dca5c31dab5b2f901bc5a48c68c
5
5
  SHA512:
6
- metadata.gz: 31339aea14f0be79d11aaac5b9c4b278a6a87201c291ba50608888339dff7e94730d9d2f6201967fac7ea7a6ce9e05da7418f964481c37bb00f875a22d1dd51e
7
- data.tar.gz: 78c68477abafc1b5391fb4b5f527d71acf6b3fa3daf0d71855d595bcbc023338c152af37744b5f7c74126cc8d684b5ac0548a08a7021dc830f078ec734f8919f
6
+ metadata.gz: a005a9271b2f926746fee1294a467f2d319af5bbd75677c3532ec4ec2fe6337ac970eda70e55cbaf6584b98235b8e27801088bfa5aff96d111251ce1b5f426a6
7
+ data.tar.gz: 55fc4b9f2754928d72251c4f88ff5dbb6534d9a209eaa3b1ce5bfd5a39941640f68b3a9c2058eecb0396693bc4b0dfa8708f8c9420700ddd56cd4a40578392e3
@@ -88,7 +88,7 @@ module MeiliSearch
88
88
  private
89
89
 
90
90
  def index_object(uid, primary_key = nil)
91
- Index.new(uid, @base_url, @api_key, primary_key)
91
+ Index.new(uid, @base_url, @api_key, primary_key, @options)
92
92
  end
93
93
  end
94
94
  end
@@ -7,6 +7,8 @@ module MeiliSearch
7
7
  class HTTPRequest
8
8
  include HTTParty
9
9
 
10
+ attr_reader :options
11
+
10
12
  def initialize(url, api_key = nil, options = {})
11
13
  @base_url = url
12
14
  @api_key = api_key
@@ -7,10 +7,10 @@ module MeiliSearch
7
7
  class Index < HTTPRequest
8
8
  attr_reader :uid, :primary_key
9
9
 
10
- def initialize(index_uid, url, api_key = nil, primary_key = nil)
10
+ def initialize(index_uid, url, api_key = nil, primary_key = nil, options = {})
11
11
  @uid = index_uid
12
12
  @primary_key = primary_key
13
- super(url, api_key)
13
+ super(url, api_key, options)
14
14
  end
15
15
 
16
16
  def fetch_info
@@ -116,7 +116,7 @@ module MeiliSearch
116
116
 
117
117
  def search(query, options = {})
118
118
  parsed_options = options.compact
119
- http_post "/indexes/#{@uid}/search", { q: query }.merge(parsed_options)
119
+ http_post "/indexes/#{@uid}/search", { q: query.to_s }.merge(parsed_options)
120
120
  end
121
121
 
122
122
  ### UPDATES
@@ -129,11 +129,15 @@ module MeiliSearch
129
129
  http_get "/indexes/#{@uid}/updates"
130
130
  end
131
131
 
132
+ def achieved_upate?(update)
133
+ update['status'] != 'enqueued' && update['status'] != 'processing'
134
+ end
135
+
132
136
  def wait_for_pending_update(update_id, timeout_in_ms = 5000, interval_in_ms = 50)
133
137
  Timeout.timeout(timeout_in_ms.to_f / 1000) do
134
138
  loop do
135
139
  get_update = get_update_status(update_id)
136
- return get_update if get_update['status'] != 'enqueued'
140
+ return get_update if achieved_upate?(get_update)
137
141
 
138
142
  sleep interval_in_ms.to_f / 1000
139
143
  end
@@ -160,8 +164,8 @@ module MeiliSearch
160
164
  stats['lastUpdate']
161
165
  end
162
166
 
163
- def fields_distribution
164
- stats['fieldsDistribution']
167
+ def field_distribution
168
+ stats['fieldDistribution']
165
169
  end
166
170
 
167
171
  ### SETTINGS - GENERAL
@@ -220,7 +224,7 @@ module MeiliSearch
220
224
  alias get_stop_words stop_words
221
225
 
222
226
  def update_stop_words(stop_words)
223
- body = stop_words.is_a?(Array) ? stop_words : [stop_words]
227
+ body = stop_words.nil? || stop_words.is_a?(Array) ? stop_words : [stop_words]
224
228
  http_post "/indexes/#{@uid}/settings/stop-words", body
225
229
  end
226
230
  alias stop_words= update_stop_words
@@ -277,20 +281,36 @@ module MeiliSearch
277
281
  http_delete "/indexes/#{@uid}/settings/displayed-attributes"
278
282
  end
279
283
 
280
- ### SETTINGS - ATTRIBUTES FOR FACETING
284
+ ### SETTINGS - FILTERABLE ATTRIBUTES
285
+
286
+ def filterable_attributes
287
+ http_get "/indexes/#{@uid}/settings/filterable-attributes"
288
+ end
289
+ alias get_filterable_attributes filterable_attributes
290
+
291
+ def update_filterable_attributes(filterable_attributes)
292
+ http_post "/indexes/#{@uid}/settings/filterable-attributes", filterable_attributes
293
+ end
294
+ alias filterable_attributes= update_filterable_attributes
295
+
296
+ def reset_filterable_attributes
297
+ http_delete "/indexes/#{@uid}/settings/filterable-attributes"
298
+ end
299
+
300
+ ### SETTINGS - SORTABLE ATTRIBUTES
281
301
 
282
- def attributes_for_faceting
283
- http_get "/indexes/#{@uid}/settings/attributes-for-faceting"
302
+ def sortable_attributes
303
+ http_get "/indexes/#{@uid}/settings/sortable-attributes"
284
304
  end
285
- alias get_attributes_for_faceting attributes_for_faceting
305
+ alias get_sortable_attributes sortable_attributes
286
306
 
287
- def update_attributes_for_faceting(attributes_for_faceting)
288
- http_post "/indexes/#{@uid}/settings/attributes-for-faceting", attributes_for_faceting
307
+ def update_sortable_attributes(sortable_attributes)
308
+ http_post "/indexes/#{@uid}/settings/sortable-attributes", sortable_attributes
289
309
  end
290
- alias attributes_for_faceting= update_attributes_for_faceting
310
+ alias sortable_attributes= update_sortable_attributes
291
311
 
292
- def reset_attributes_for_faceting
293
- http_delete "/indexes/#{@uid}/settings/attributes-for-faceting"
312
+ def reset_sortable_attributes
313
+ http_delete "/indexes/#{@uid}/settings/sortable-attributes"
294
314
  end
295
315
  end
296
316
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeiliSearch
4
- VERSION = '0.15.2'
4
+ VERSION = '0.16.1'
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.15.2
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 0.17.1
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: 0.19.0
22
+ version: 0.20.0
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 0.17.1
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: 0.19.0
32
+ version: 0.20.0
33
33
  description: An easy-to-use ruby client for Meilisearch API. See https://github.com/meilisearch/MeiliSearch
34
34
  email: bonjour@meilisearch.com
35
35
  executables: []