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 +4 -4
- data/lib/meilisearch/client.rb +1 -1
- data/lib/meilisearch/http_request.rb +3 -1
- data/lib/meilisearch/index.rb +20 -16
- data/lib/meilisearch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c67baca928880c0efd95580e84a4b3f11f8fbab279a8eec5e6a7ffd64467ce85
|
4
|
+
data.tar.gz: ee39b314f6607c5ccd219d16bb6e0cb88d971b7113fa1c9091b11634b34e5062
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa7d0a46d608c88ac58786f70d95001c845123c5df29fe3644ddfe8669f87744102076a6610b993b05dd733512922def3ece255fcd562dac103696f07c779a66
|
7
|
+
data.tar.gz: e6b254f4fc93e8e9f4a0f6aa8df701fbd30cc6565021c0c61f81e709fc96b3423ca0eb4cc6097eb2abba91c76ea6298128e4765c9f2f1f3ce58ba807a8d93bb7
|
data/lib/meilisearch/client.rb
CHANGED
@@ -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
|
68
|
+
body = body.to_json
|
67
69
|
{
|
68
70
|
headers: @headers,
|
69
71
|
query: query_params,
|
data/lib/meilisearch/index.rb
CHANGED
@@ -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
|
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
|
164
|
-
stats['
|
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
|
284
|
+
### SETTINGS - FILTERABLE ATTRIBUTES
|
281
285
|
|
282
|
-
def
|
283
|
-
http_get "/indexes/#{@uid}/settings/attributes
|
286
|
+
def filterable_attributes
|
287
|
+
http_get "/indexes/#{@uid}/settings/filterable-attributes"
|
284
288
|
end
|
285
|
-
alias
|
289
|
+
alias get_filterable_attributes filterable_attributes
|
286
290
|
|
287
|
-
def
|
288
|
-
http_post "/indexes/#{@uid}/settings/attributes
|
291
|
+
def update_filterable_attributes(filterable_attributes)
|
292
|
+
http_post "/indexes/#{@uid}/settings/filterable-attributes", filterable_attributes
|
289
293
|
end
|
290
|
-
alias
|
294
|
+
alias filterable_attributes= update_filterable_attributes
|
291
295
|
|
292
|
-
def
|
293
|
-
http_delete "/indexes/#{@uid}/settings/attributes
|
296
|
+
def reset_filterable_attributes
|
297
|
+
http_delete "/indexes/#{@uid}/settings/filterable-attributes"
|
294
298
|
end
|
295
299
|
end
|
296
300
|
end
|
data/lib/meilisearch/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2021-08-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|