meilisearch 0.15.1 → 0.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9782242369c3ad58f78c3acb55a0e78440c8a83e27018b2a3f0b425bccbbb3ae
4
- data.tar.gz: 8b9ba817a3fb87ea17058a25550f38758d355df2f6c3c83b4e8f30273f2390c0
3
+ metadata.gz: c67baca928880c0efd95580e84a4b3f11f8fbab279a8eec5e6a7ffd64467ce85
4
+ data.tar.gz: ee39b314f6607c5ccd219d16bb6e0cb88d971b7113fa1c9091b11634b34e5062
5
5
  SHA512:
6
- metadata.gz: 76e831c930ab8b01943972fee81df852d811bd2ca1f35be0f953dac1319bd59476799d5ad0d41c72f4a39b2737001a0b1c3f06780c86ace4f32d73eb4dcf424b
7
- data.tar.gz: fbcdef31995193bcf885e8a8ff837031b1882e329be90ab205c3a3d97b2d4d5f22cdf9e0af6dcc0694fc9ae56b2be5a2717a98aeaae568604dd16d7182fb8abe
6
+ metadata.gz: aa7d0a46d608c88ac58786f70d95001c845123c5df29fe3644ddfe8669f87744102076a6610b993b05dd733512922def3ece255fcd562dac103696f07c779a66
7
+ data.tar.gz: e6b254f4fc93e8e9f4a0f6aa8df701fbd30cc6565021c0c61f81e709fc96b3423ca0eb4cc6097eb2abba91c76ea6298128e4765c9f2f1f3ce58ba807a8d93bb7
@@ -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
@@ -63,7 +65,7 @@ module MeiliSearch
63
65
  end
64
66
 
65
67
  def http_config(query_params, body)
66
- body = body.to_json unless body.nil?
68
+ body = body.to_json
67
69
  {
68
70
  headers: @headers,
69
71
  query: query_params,
@@ -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,20 @@ 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
281
285
 
282
- def attributes_for_faceting
283
- http_get "/indexes/#{@uid}/settings/attributes-for-faceting"
286
+ def filterable_attributes
287
+ http_get "/indexes/#{@uid}/settings/filterable-attributes"
284
288
  end
285
- alias get_attributes_for_faceting attributes_for_faceting
289
+ alias get_filterable_attributes filterable_attributes
286
290
 
287
- def update_attributes_for_faceting(attributes_for_faceting)
288
- http_post "/indexes/#{@uid}/settings/attributes-for-faceting", attributes_for_faceting
291
+ def update_filterable_attributes(filterable_attributes)
292
+ http_post "/indexes/#{@uid}/settings/filterable-attributes", filterable_attributes
289
293
  end
290
- alias attributes_for_faceting= update_attributes_for_faceting
294
+ alias filterable_attributes= update_filterable_attributes
291
295
 
292
- def reset_attributes_for_faceting
293
- http_delete "/indexes/#{@uid}/settings/attributes-for-faceting"
296
+ def reset_filterable_attributes
297
+ http_delete "/indexes/#{@uid}/settings/filterable-attributes"
294
298
  end
295
299
  end
296
300
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MeiliSearch
4
- VERSION = '0.15.1'
4
+ VERSION = '0.16.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.15.1
4
+ version: 0.16.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Meili
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-19 00:00:00.000000000 Z
11
+ date: 2021-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty