meilisearch 0.17.0 → 0.17.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/meilisearch/client.rb +2 -1
- data/lib/meilisearch/http_request.rb +1 -23
- data/lib/meilisearch/index.rb +7 -5
- data/lib/meilisearch/version.rb +1 -1
- data/lib/meilisearch.rb +1 -0
- 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: d989f446194c8260cc87880abfaaf641d0e4b88ae80300d7f9d99fd4c6edfd2e
|
4
|
+
data.tar.gz: cbec6b1faeab1d84990b7b1390eb386e536bbaa2442231593d1377b5a5ba0da4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 328b4fcec0d6ca099c34ee40340a5a191cec576cbef198a4b0a18fd0afaa1c77708146531204347e67a0037599a35b7caa514940674f28e5a8b06ecaba7ba55c
|
7
|
+
data.tar.gz: db01b2e587efc423138437505840b73879d26a0a5d340eb3f1ea56753b8e2f7eaba6f13b22e1a464c8bfec9728b1af42e0c164a735e624844a1a81a99504bd5f
|
data/lib/meilisearch/client.rb
CHANGED
@@ -20,7 +20,8 @@ module MeiliSearch
|
|
20
20
|
# client.create_index('indexUID')
|
21
21
|
# client.create_index('indexUID', primaryKey: 'id')
|
22
22
|
def create_index(index_uid, options = {})
|
23
|
-
body = options.merge(uid: index_uid)
|
23
|
+
body = Utils.transform_attributes(options.merge(uid: index_uid))
|
24
|
+
|
24
25
|
index_hash = http_post '/indexes', body
|
25
26
|
index_object(index_hash['uid'], index_hash['primaryKey'])
|
26
27
|
end
|
@@ -61,8 +61,6 @@ module MeiliSearch
|
|
61
61
|
|
62
62
|
private
|
63
63
|
|
64
|
-
SNAKE_CASE = /[^a-zA-Z0-9]+(.)/.freeze
|
65
|
-
|
66
64
|
def send_request(http_method, relative_path, query_params: nil, body: nil, headers: nil)
|
67
65
|
config = http_config(query_params, body, headers)
|
68
66
|
begin
|
@@ -74,35 +72,15 @@ module MeiliSearch
|
|
74
72
|
end
|
75
73
|
|
76
74
|
def http_config(query_params, body, headers)
|
77
|
-
body = transform_attributes(body).to_json
|
78
75
|
{
|
79
76
|
headers: headers,
|
80
77
|
query: query_params,
|
81
|
-
body: body,
|
78
|
+
body: body.to_json,
|
82
79
|
timeout: @options[:timeout] || 1,
|
83
80
|
max_retries: @options[:max_retries] || 0
|
84
81
|
}.compact
|
85
82
|
end
|
86
83
|
|
87
|
-
def transform_attributes(body)
|
88
|
-
case body
|
89
|
-
when Array
|
90
|
-
body.map { |item| transform_attributes(item) }
|
91
|
-
when Hash
|
92
|
-
parse(body)
|
93
|
-
else
|
94
|
-
body
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
def parse(body)
|
99
|
-
body
|
100
|
-
.transform_keys(&:to_s)
|
101
|
-
.transform_keys do |key|
|
102
|
-
key.include?('_') ? key.downcase.gsub(SNAKE_CASE, &:upcase).gsub('_', '') : key
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
84
|
def validate(response)
|
107
85
|
raise ApiError.new(response.code, response.message, response.body) unless response.success?
|
108
86
|
|
data/lib/meilisearch/index.rb
CHANGED
@@ -31,8 +31,9 @@ module MeiliSearch
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def update(body)
|
34
|
-
index_hash = http_put indexes_path(id: @uid), body
|
34
|
+
index_hash = http_put indexes_path(id: @uid), Utils.transform_attributes(body)
|
35
35
|
set_base_properties index_hash
|
36
|
+
|
36
37
|
self
|
37
38
|
end
|
38
39
|
|
@@ -65,7 +66,7 @@ module MeiliSearch
|
|
65
66
|
alias get_one_document document
|
66
67
|
|
67
68
|
def documents(options = {})
|
68
|
-
http_get "/indexes/#{@uid}/documents", options
|
69
|
+
http_get "/indexes/#{@uid}/documents", Utils.transform_attributes(options)
|
69
70
|
end
|
70
71
|
alias get_documents documents
|
71
72
|
|
@@ -168,8 +169,9 @@ module MeiliSearch
|
|
168
169
|
### SEARCH
|
169
170
|
|
170
171
|
def search(query, options = {})
|
171
|
-
parsed_options = options.compact
|
172
|
-
|
172
|
+
parsed_options = Utils.transform_attributes({ q: query.to_s }.merge(options.compact))
|
173
|
+
|
174
|
+
http_post "/indexes/#{@uid}/search", parsed_options
|
173
175
|
end
|
174
176
|
|
175
177
|
### UPDATES
|
@@ -229,7 +231,7 @@ module MeiliSearch
|
|
229
231
|
alias get_settings settings
|
230
232
|
|
231
233
|
def update_settings(settings)
|
232
|
-
http_post "/indexes/#{@uid}/settings", settings
|
234
|
+
http_post "/indexes/#{@uid}/settings", Utils.transform_attributes(settings)
|
233
235
|
end
|
234
236
|
alias settings= update_settings
|
235
237
|
|
data/lib/meilisearch/version.rb
CHANGED
data/lib/meilisearch.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.17.
|
4
|
+
version: 0.17.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-11-
|
11
|
+
date: 2021-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|