meilisearch 0.29.0 → 0.31.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +3 -18
- data/lib/meilisearch/client.rb +13 -3
- data/lib/meilisearch/error.rb +13 -13
- data/lib/meilisearch/http_request.rb +14 -14
- data/lib/meilisearch/index.rb +158 -6
- data/lib/meilisearch/models/task.rb +2 -2
- data/lib/meilisearch/multi_search.rb +14 -4
- data/lib/meilisearch/task.rb +3 -3
- data/lib/meilisearch/tenant_token.rb +1 -1
- data/lib/meilisearch/utils.rb +3 -3
- data/lib/meilisearch/version.rb +2 -2
- data/lib/meilisearch.rb +35 -0
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6cedcf8f0f86e12bfaee3c4f1464af380f1b6df1943746fc2f954aba8aa1090
|
4
|
+
data.tar.gz: c387d93dcfbf3fadd5682469c2b0aab284603afbfa503d77fc9ee674966a724a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbd5af58608cb342538232663cddc27d073af9aa3d598385c9a227ef615eb556b8c0f0f6195a977fe89ac542b4efd635aae14747a82b21a821c89272ab619b22
|
7
|
+
data.tar.gz: 15caa179a6f58ff36d2ec4abf1d9b40f8477ba62cbfe49cf0f3944465ed1a2b2c8a5cdc69ab15f9ecc42ca525ce6b553adc17444727adf46d1161ec8b1732e1f
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -33,7 +33,6 @@
|
|
33
33
|
## Table of Contents <!-- omit in TOC -->
|
34
34
|
|
35
35
|
- [📖 Documentation](#-documentation)
|
36
|
-
- [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
|
37
36
|
- [🔧 Installation](#-installation)
|
38
37
|
- [🚀 Getting started](#-getting-started)
|
39
38
|
- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
|
@@ -47,10 +46,6 @@ This readme contains all the documentation you need to start using this Meilisea
|
|
47
46
|
For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our [main documentation website](https://www.meilisearch.com/docs/).
|
48
47
|
|
49
48
|
|
50
|
-
## ⚡ Supercharge your Meilisearch experience
|
51
|
-
|
52
|
-
Say goodbye to server deployment and manual updates with [Meilisearch Cloud](https://www.meilisearch.com/cloud?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-ruby). Get started with a 14-day free trial! No credit card required.
|
53
|
-
|
54
49
|
## 🔧 Installation
|
55
50
|
|
56
51
|
We officially support any version of Ruby that is still receiving at least [security maintenance](https://www.ruby-lang.org/en/downloads/branches/). You may, however, be fine with any Ruby version above 3.0.
|
@@ -70,19 +65,9 @@ gem 'meilisearch'
|
|
70
65
|
|
71
66
|
### Run Meilisearch <!-- omit in toc -->
|
72
67
|
|
73
|
-
|
74
|
-
|
75
|
-
For example, using the `curl` command in your [Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/what-is-a-terminal/):
|
76
|
-
|
77
|
-
```sh
|
78
|
-
# Install Meilisearch
|
79
|
-
curl -L https://install.meilisearch.com | sh
|
80
|
-
|
81
|
-
# Launch Meilisearch
|
82
|
-
./meilisearch --master-key=masterKey
|
83
|
-
```
|
68
|
+
⚡️ **Launch, scale, and streamline in minutes with Meilisearch Cloud**—no maintenance, no commitment, cancel anytime. [Try it free now](https://cloud.meilisearch.com/login?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-ruby).
|
84
69
|
|
85
|
-
|
70
|
+
🪨 Prefer to self-host? [Download and deploy](https://www.meilisearch.com/docs/learn/self_hosted/getting_started_with_self_hosted_meilisearch?utm_campaign=oss&utm_source=github&utm_medium=meilisearch-ruby) our fast, open-source search engine on your own infrastructure.
|
86
71
|
|
87
72
|
## 🚀 Getting started
|
88
73
|
|
@@ -91,7 +76,7 @@ NB: you can also download Meilisearch from **Homebrew** or **APT** or even run i
|
|
91
76
|
```ruby
|
92
77
|
require 'meilisearch'
|
93
78
|
|
94
|
-
client =
|
79
|
+
client = Meilisearch::Client.new('http://127.0.0.1:7700', 'masterKey')
|
95
80
|
|
96
81
|
# An index is where the documents are stored.
|
97
82
|
index = client.index('movies')
|
data/lib/meilisearch/client.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module Meilisearch
|
4
4
|
class Client < HTTPRequest
|
5
|
-
include
|
6
|
-
include
|
5
|
+
include Meilisearch::TenantToken
|
6
|
+
include Meilisearch::MultiSearch
|
7
7
|
|
8
8
|
### INDEXES
|
9
9
|
|
@@ -157,6 +157,16 @@ module MeiliSearch
|
|
157
157
|
task_endpoint.wait_for_task(task_uid, timeout_in_ms, interval_in_ms)
|
158
158
|
end
|
159
159
|
|
160
|
+
### BATCHES
|
161
|
+
|
162
|
+
def batches(options = {})
|
163
|
+
http_get '/batches', options
|
164
|
+
end
|
165
|
+
|
166
|
+
def batch(batch_uid)
|
167
|
+
http_get "/batches/#{batch_uid}"
|
168
|
+
end
|
169
|
+
|
160
170
|
private
|
161
171
|
|
162
172
|
def index_object(uid, primary_key = nil)
|
data/lib/meilisearch/error.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module Meilisearch
|
4
4
|
class Error < StandardError
|
5
5
|
end
|
6
6
|
|
7
7
|
class ApiError < Error
|
8
8
|
# :http_code # e.g. 400, 404...
|
9
9
|
# :http_message # e.g. Bad Request, Not Found...
|
10
|
-
# :http_body # The response body received from the
|
11
|
-
# :ms_code # The error code given by the
|
12
|
-
# :ms_type # The error type given by the
|
13
|
-
# :ms_link # The documentation link given by the
|
14
|
-
# :ms_message # The error message given by the
|
10
|
+
# :http_body # The response body received from the Meilisearch API
|
11
|
+
# :ms_code # The error code given by the Meilisearch API
|
12
|
+
# :ms_type # The error type given by the Meilisearch API
|
13
|
+
# :ms_link # The documentation link given by the Meilisearch API
|
14
|
+
# :ms_message # The error message given by the Meilisearch API
|
15
15
|
# :message # The detailed error message of this error class
|
16
16
|
|
17
17
|
attr_reader :http_code, :http_message, :http_body, :ms_code, :ms_type, :ms_link, :ms_message, :message
|
@@ -26,7 +26,7 @@ module MeiliSearch
|
|
26
26
|
@http_body = parse_body(http_body)
|
27
27
|
@ms_code = @http_body['code']
|
28
28
|
@ms_type = @http_body['type']
|
29
|
-
@ms_message = @http_body.fetch('message', '
|
29
|
+
@ms_message = @http_body.fetch('message', 'Meilisearch API has not returned any error message')
|
30
30
|
@ms_link = @http_body.fetch('link', '<no documentation link found>')
|
31
31
|
@message = "#{http_code} #{http_message} - #{@ms_message}. See #{ms_link}."
|
32
32
|
super(details)
|
@@ -41,14 +41,14 @@ module MeiliSearch
|
|
41
41
|
{}
|
42
42
|
end
|
43
43
|
rescue JSON::ParserError
|
44
|
-
# We might receive a JSON::ParserError when, for example,
|
44
|
+
# We might receive a JSON::ParserError when, for example, Meilisearch is running behind
|
45
45
|
# some proxy (ELB or Nginx, for example), and the request timeouts, returning us
|
46
46
|
# a raw HTML body instead of a JSON as we were expecting
|
47
47
|
{ 'message' => "The server has not returned a valid JSON HTTP body: #{http_body}" }
|
48
48
|
end
|
49
49
|
|
50
50
|
def details
|
51
|
-
"
|
51
|
+
"Meilisearch::ApiError - code: #{@ms_code} - type: #{ms_type} - message: #{@ms_message} - link: #{ms_link}"
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
@@ -56,7 +56,7 @@ module MeiliSearch
|
|
56
56
|
attr_reader :message
|
57
57
|
|
58
58
|
def initialize(message)
|
59
|
-
@message = "An error occurred while trying to connect to the
|
59
|
+
@message = "An error occurred while trying to connect to the Meilisearch instance: #{message}"
|
60
60
|
super(@message)
|
61
61
|
end
|
62
62
|
end
|
@@ -80,8 +80,8 @@ module MeiliSearch
|
|
80
80
|
end
|
81
81
|
|
82
82
|
module TenantToken
|
83
|
-
class ExpireOrInvalidSignature <
|
84
|
-
class InvalidApiKey <
|
85
|
-
class InvalidSearchRules <
|
83
|
+
class ExpireOrInvalidSignature < Meilisearch::Error; end
|
84
|
+
class InvalidApiKey < Meilisearch::Error; end
|
85
|
+
class InvalidSearchRules < Meilisearch::Error; end
|
86
86
|
end
|
87
87
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'httparty'
|
4
4
|
require 'meilisearch/error'
|
5
5
|
|
6
|
-
module
|
6
|
+
module Meilisearch
|
7
7
|
class HTTPRequest
|
8
8
|
include HTTParty
|
9
9
|
|
@@ -22,14 +22,14 @@ module MeiliSearch
|
|
22
22
|
@headers = build_default_options_headers
|
23
23
|
end
|
24
24
|
|
25
|
-
def http_get(relative_path = '', query_params = {})
|
25
|
+
def http_get(relative_path = '', query_params = {}, options = {})
|
26
26
|
send_request(
|
27
27
|
proc { |path, config| self.class.get(path, config) },
|
28
28
|
relative_path,
|
29
29
|
config: {
|
30
30
|
query_params: query_params,
|
31
|
-
headers: remove_headers(@headers.dup, 'Content-Type'),
|
32
|
-
options: @options
|
31
|
+
headers: remove_headers(@headers.dup.merge(options[:headers] || {}), 'Content-Type'),
|
32
|
+
options: @options.merge(options)
|
33
33
|
}
|
34
34
|
)
|
35
35
|
end
|
@@ -47,40 +47,40 @@ module MeiliSearch
|
|
47
47
|
)
|
48
48
|
end
|
49
49
|
|
50
|
-
def http_put(relative_path = '', body = nil, query_params = nil)
|
50
|
+
def http_put(relative_path = '', body = nil, query_params = nil, options = {})
|
51
51
|
send_request(
|
52
52
|
proc { |path, config| self.class.put(path, config) },
|
53
53
|
relative_path,
|
54
54
|
config: {
|
55
55
|
query_params: query_params,
|
56
56
|
body: body,
|
57
|
-
headers: @headers,
|
58
|
-
options: @options
|
57
|
+
headers: @headers.dup.merge(options[:headers] || {}),
|
58
|
+
options: @options.merge(options)
|
59
59
|
}
|
60
60
|
)
|
61
61
|
end
|
62
62
|
|
63
|
-
def http_patch(relative_path = '', body = nil, query_params = nil)
|
63
|
+
def http_patch(relative_path = '', body = nil, query_params = nil, options = {})
|
64
64
|
send_request(
|
65
65
|
proc { |path, config| self.class.patch(path, config) },
|
66
66
|
relative_path,
|
67
67
|
config: {
|
68
68
|
query_params: query_params,
|
69
69
|
body: body,
|
70
|
-
headers: @headers,
|
71
|
-
options: @options
|
70
|
+
headers: @headers.dup.merge(options[:headers] || {}),
|
71
|
+
options: @options.merge(options)
|
72
72
|
}
|
73
73
|
)
|
74
74
|
end
|
75
75
|
|
76
|
-
def http_delete(relative_path = '', query_params = nil)
|
76
|
+
def http_delete(relative_path = '', query_params = nil, options = {})
|
77
77
|
send_request(
|
78
78
|
proc { |path, config| self.class.delete(path, config) },
|
79
79
|
relative_path,
|
80
80
|
config: {
|
81
81
|
query_params: query_params,
|
82
|
-
headers: remove_headers(@headers.dup, 'Content-Type'),
|
83
|
-
options: @options
|
82
|
+
headers: remove_headers(@headers.dup.merge(options[:headers] || {}), 'Content-Type'),
|
83
|
+
options: @options.merge(options)
|
84
84
|
}
|
85
85
|
)
|
86
86
|
end
|
@@ -93,7 +93,7 @@ module MeiliSearch
|
|
93
93
|
'Authorization' => ("Bearer #{@api_key}" unless @api_key.nil?),
|
94
94
|
'User-Agent' => [
|
95
95
|
@options.fetch(:client_agents, []),
|
96
|
-
|
96
|
+
Meilisearch.qualified_version
|
97
97
|
].flatten.join(';')
|
98
98
|
}.compact
|
99
99
|
end
|
data/lib/meilisearch/index.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'meilisearch/http_request'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Meilisearch
|
6
6
|
class Index < HTTPRequest
|
7
7
|
attr_reader :uid, :primary_key, :created_at, :updated_at
|
8
8
|
|
@@ -145,6 +145,48 @@ module MeiliSearch
|
|
145
145
|
end
|
146
146
|
alias add_or_update_documents update_documents
|
147
147
|
|
148
|
+
def update_documents_json(documents, primary_key = nil)
|
149
|
+
options = { convert_body?: false }
|
150
|
+
response = http_put "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
|
151
|
+
|
152
|
+
Models::Task.new(response, task_endpoint)
|
153
|
+
end
|
154
|
+
alias add_or_update_documents_json update_documents_json
|
155
|
+
|
156
|
+
def update_documents_ndjson(documents, primary_key = nil)
|
157
|
+
options = { headers: { 'Content-Type' => 'application/x-ndjson' }, convert_body?: false }
|
158
|
+
response = http_put "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
|
159
|
+
|
160
|
+
Models::Task.new(response, task_endpoint)
|
161
|
+
end
|
162
|
+
alias add_or_update_documents_ndjson update_documents_ndjson
|
163
|
+
|
164
|
+
def update_documents_csv(documents, primary_key = nil, delimiter = nil)
|
165
|
+
options = { headers: { 'Content-Type' => 'text/csv' }, convert_body?: false }
|
166
|
+
|
167
|
+
response = http_put "/indexes/#{@uid}/documents", documents, {
|
168
|
+
primaryKey: primary_key,
|
169
|
+
csvDelimiter: delimiter
|
170
|
+
}.compact, options
|
171
|
+
|
172
|
+
Models::Task.new(response, task_endpoint)
|
173
|
+
end
|
174
|
+
alias add_or_update_documents_csv add_documents_csv
|
175
|
+
|
176
|
+
def update_documents_ndjson_in_batches(documents, batch_size = 1000, primary_key = nil)
|
177
|
+
documents.lines.each_slice(batch_size).map do |batch|
|
178
|
+
update_documents_ndjson(batch.join, primary_key)
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
def update_documents_csv_in_batches(documents, batch_size = 1000, primary_key = nil, delimiter = nil)
|
183
|
+
lines = documents.lines
|
184
|
+
heading = lines.first
|
185
|
+
lines.drop(1).each_slice(batch_size).map do |batch|
|
186
|
+
update_documents_csv(heading + batch.join, primary_key, delimiter)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
148
190
|
def update_documents!(documents, primary_key = nil)
|
149
191
|
Utils.soft_deprecate(
|
150
192
|
'Index#update_documents!',
|
@@ -161,6 +203,20 @@ module MeiliSearch
|
|
161
203
|
end
|
162
204
|
end
|
163
205
|
|
206
|
+
def add_documents_ndjson_in_batches(documents, batch_size = 1000, primary_key = nil)
|
207
|
+
documents.lines.each_slice(batch_size).map do |batch|
|
208
|
+
add_documents_ndjson(batch.join, primary_key)
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
def add_documents_csv_in_batches(documents, batch_size = 1000, primary_key = nil, delimiter = nil)
|
213
|
+
lines = documents.lines
|
214
|
+
heading = lines.first
|
215
|
+
lines.drop(1).each_slice(batch_size).map do |batch|
|
216
|
+
add_documents_csv(heading + batch.join, primary_key, delimiter)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
164
220
|
def add_documents_in_batches!(documents, batch_size = 1000, primary_key = nil)
|
165
221
|
Utils.soft_deprecate(
|
166
222
|
'Index#add_documents_in_batches!',
|
@@ -185,6 +241,18 @@ module MeiliSearch
|
|
185
241
|
update_documents_in_batches(documents, batch_size, primary_key).each(&:await)
|
186
242
|
end
|
187
243
|
|
244
|
+
# Update documents by function
|
245
|
+
#
|
246
|
+
# options - A Hash containing the function string and related options
|
247
|
+
# context:
|
248
|
+
# filter:
|
249
|
+
# function:
|
250
|
+
def update_documents_by_function(options)
|
251
|
+
response = http_post "/indexes/#{@uid}/documents/edit", options
|
252
|
+
|
253
|
+
Models::Task.new(response, task_endpoint)
|
254
|
+
end
|
255
|
+
|
188
256
|
# Public: Delete documents from an index
|
189
257
|
#
|
190
258
|
# options: A Hash or an Array containing documents_ids or a hash with filter:.
|
@@ -221,7 +289,7 @@ module MeiliSearch
|
|
221
289
|
|
222
290
|
def delete_document(document_id)
|
223
291
|
if document_id.nil? || document_id.to_s.empty?
|
224
|
-
raise
|
292
|
+
raise Meilisearch::InvalidDocumentId, 'document_id cannot be empty or nil'
|
225
293
|
end
|
226
294
|
|
227
295
|
encode_document = URI.encode_www_form_component(document_id)
|
@@ -597,11 +665,15 @@ module MeiliSearch
|
|
597
665
|
end
|
598
666
|
|
599
667
|
def update_proximity_precision(proximity_precision_attribute)
|
600
|
-
http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
|
668
|
+
response = http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
|
669
|
+
|
670
|
+
Models::Task.new(response, task_endpoint)
|
601
671
|
end
|
602
672
|
|
603
673
|
def reset_proximity_precision
|
604
|
-
http_delete("/indexes/#{@uid}/settings/proximity-precision")
|
674
|
+
response = http_delete("/indexes/#{@uid}/settings/proximity-precision")
|
675
|
+
|
676
|
+
Models::Task.new(response, task_endpoint)
|
605
677
|
end
|
606
678
|
|
607
679
|
### SETTINGS - SEARCH CUTOFF MS
|
@@ -611,11 +683,91 @@ module MeiliSearch
|
|
611
683
|
end
|
612
684
|
|
613
685
|
def update_search_cutoff_ms(search_cutoff_ms_attribute)
|
614
|
-
http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
|
686
|
+
response = http_put("/indexes/#{@uid}/settings/search-cutoff-ms", search_cutoff_ms_attribute)
|
687
|
+
|
688
|
+
Models::Task.new(response, task_endpoint)
|
615
689
|
end
|
616
690
|
|
617
691
|
def reset_search_cutoff_ms
|
618
|
-
http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
|
692
|
+
response = http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
|
693
|
+
|
694
|
+
Models::Task.new(response, task_endpoint)
|
695
|
+
end
|
696
|
+
|
697
|
+
### SETTINGS - LOCALIZED ATTRIBUTES
|
698
|
+
|
699
|
+
def localized_attributes
|
700
|
+
http_get("/indexes/#{@uid}/settings/localized-attributes")
|
701
|
+
end
|
702
|
+
|
703
|
+
def update_localized_attributes(new_localized_attributes)
|
704
|
+
new_localized_attributes = Utils.transform_attributes(new_localized_attributes)
|
705
|
+
|
706
|
+
response = http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
|
707
|
+
|
708
|
+
Models::Task.new(response, task_endpoint)
|
709
|
+
end
|
710
|
+
|
711
|
+
def reset_localized_attributes
|
712
|
+
response = http_delete("/indexes/#{@uid}/settings/localized-attributes")
|
713
|
+
|
714
|
+
Models::Task.new(response, task_endpoint)
|
715
|
+
end
|
716
|
+
|
717
|
+
### SETTINGS - FACET SEARCH
|
718
|
+
|
719
|
+
def facet_search_setting
|
720
|
+
http_get("/indexes/#{@uid}/settings/facet-search")
|
721
|
+
end
|
722
|
+
|
723
|
+
def update_facet_search_setting(new_facet_search_setting)
|
724
|
+
response = http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
|
725
|
+
|
726
|
+
Models::Task.new(response, task_endpoint)
|
727
|
+
end
|
728
|
+
|
729
|
+
def reset_facet_search_setting
|
730
|
+
response = http_delete("/indexes/#{@uid}/settings/facet-search")
|
731
|
+
|
732
|
+
Models::Task.new(response, task_endpoint)
|
733
|
+
end
|
734
|
+
|
735
|
+
### SETTINGS - PREFIX SEARCH
|
736
|
+
|
737
|
+
def prefix_search
|
738
|
+
http_get("/indexes/#{@uid}/settings/prefix-search")
|
739
|
+
end
|
740
|
+
|
741
|
+
def update_prefix_search(new_prefix_search_setting)
|
742
|
+
response = http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
|
743
|
+
|
744
|
+
Models::Task.new(response, task_endpoint)
|
745
|
+
end
|
746
|
+
|
747
|
+
def reset_prefix_search
|
748
|
+
response = http_delete("/indexes/#{@uid}/settings/prefix-search")
|
749
|
+
|
750
|
+
Models::Task.new(response, task_endpoint)
|
751
|
+
end
|
752
|
+
|
753
|
+
### SETTINGS - EMBEDDERS
|
754
|
+
|
755
|
+
def embedders
|
756
|
+
http_get("/indexes/#{@uid}/settings/embedders")
|
757
|
+
end
|
758
|
+
|
759
|
+
def update_embedders(new_embedders)
|
760
|
+
new_embedders = Utils.transform_attributes(new_embedders)
|
761
|
+
|
762
|
+
response = http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
|
763
|
+
|
764
|
+
Models::Task.new(response, task_endpoint)
|
765
|
+
end
|
766
|
+
|
767
|
+
def reset_embedders
|
768
|
+
response = http_delete("/indexes/#{@uid}/settings/embedders")
|
769
|
+
|
770
|
+
Models::Task.new(response, task_endpoint)
|
619
771
|
end
|
620
772
|
end
|
621
773
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'forwardable'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Meilisearch
|
6
6
|
module Models
|
7
7
|
class Task
|
8
8
|
extend Forwardable
|
@@ -88,7 +88,7 @@ module MeiliSearch
|
|
88
88
|
self.metadata = with || @task_endpoint.task(uid)
|
89
89
|
|
90
90
|
self
|
91
|
-
rescue
|
91
|
+
rescue Meilisearch::ApiError => e
|
92
92
|
raise e unless e.http_code == 404
|
93
93
|
|
94
94
|
@deleted = true
|
@@ -1,11 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
module
|
3
|
+
module Meilisearch
|
4
4
|
module MultiSearch
|
5
|
-
|
6
|
-
|
5
|
+
# Performs search on one or more indexes
|
6
|
+
#
|
7
|
+
# @param [Hash] federation_options
|
8
|
+
# - `limit`: number of results in the merged list
|
9
|
+
# - `offset`: number of results to skip in the merged list
|
10
|
+
def multi_search(data = nil, queries: [], federation: nil)
|
11
|
+
Utils.soft_deprecate('multi_search([])', 'multi_search(queries: [])') if data
|
7
12
|
|
8
|
-
|
13
|
+
queries += data if data
|
14
|
+
|
15
|
+
queries = Utils.transform_attributes(queries)
|
16
|
+
federation = Utils.transform_attributes(federation)
|
17
|
+
|
18
|
+
http_post '/multi-search', queries: queries, federation: federation
|
9
19
|
end
|
10
20
|
end
|
11
21
|
end
|
data/lib/meilisearch/task.rb
CHANGED
@@ -3,12 +3,12 @@
|
|
3
3
|
require 'meilisearch/http_request'
|
4
4
|
require 'timeout'
|
5
5
|
|
6
|
-
module
|
6
|
+
module Meilisearch
|
7
7
|
class Task < HTTPRequest
|
8
8
|
ALLOWED_PARAMS = [
|
9
9
|
:limit, :from, :index_uids, :types, :statuses, :uids, :canceled_by,
|
10
10
|
:before_enqueued_at, :after_enqueued_at, :before_started_at, :after_started_at,
|
11
|
-
:before_finished_at, :after_finished_at
|
11
|
+
:before_finished_at, :after_finished_at, :reverse
|
12
12
|
].freeze
|
13
13
|
ALLOWED_CANCELATION_PARAMS = (ALLOWED_PARAMS - [:limit, :from]).freeze
|
14
14
|
|
@@ -46,7 +46,7 @@ module MeiliSearch
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
rescue Timeout::Error
|
49
|
-
raise
|
49
|
+
raise Meilisearch::TimeoutError
|
50
50
|
end
|
51
51
|
|
52
52
|
private
|
data/lib/meilisearch/utils.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require 'logger'
|
4
4
|
|
5
|
-
module
|
5
|
+
module Meilisearch
|
6
6
|
module Utils
|
7
7
|
SNAKE_CASE = /[^a-zA-Z0-9]+(.)/
|
8
8
|
|
@@ -57,10 +57,10 @@ module MeiliSearch
|
|
57
57
|
|
58
58
|
def version_error_handler(method_name)
|
59
59
|
yield if block_given?
|
60
|
-
rescue
|
60
|
+
rescue Meilisearch::ApiError => e
|
61
61
|
message = message_builder(e.http_message, method_name)
|
62
62
|
|
63
|
-
raise
|
63
|
+
raise Meilisearch::ApiError.new(e.http_code, message, e.http_body)
|
64
64
|
rescue StandardError => e
|
65
65
|
raise e.class, message_builder(e.message, method_name)
|
66
66
|
end
|
data/lib/meilisearch/version.rb
CHANGED
data/lib/meilisearch.rb
CHANGED
@@ -12,5 +12,40 @@ require 'meilisearch/task'
|
|
12
12
|
require 'meilisearch/client'
|
13
13
|
require 'meilisearch/index'
|
14
14
|
|
15
|
+
module Meilisearch
|
16
|
+
end
|
17
|
+
|
18
|
+
# Softly deprecate the old spelling of the top level module
|
19
|
+
# from MeiliSearch to Meilisearch
|
15
20
|
module MeiliSearch
|
21
|
+
class << self
|
22
|
+
def const_missing(const_name)
|
23
|
+
_warn_about_deprecation
|
24
|
+
|
25
|
+
Meilisearch.const_get(const_name)
|
26
|
+
end
|
27
|
+
|
28
|
+
def method_missing(method_name, *args, **kwargs)
|
29
|
+
_warn_about_deprecation
|
30
|
+
|
31
|
+
Meilisearch.send(method_name, *args, **kwargs)
|
32
|
+
end
|
33
|
+
|
34
|
+
def respond_to_missing?(method_name, *)
|
35
|
+
Meilisearch.respond_to?(method_name) || super
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def _warn_about_deprecation
|
41
|
+
return if @warned
|
42
|
+
|
43
|
+
Meilisearch::Utils.logger.warn <<~RENAMED_MODULE_WARNING
|
44
|
+
[meilisearch-ruby] The top-level module of Meilisearch has been renamed.
|
45
|
+
[meilisearch-ruby] Please update "MeiliSearch" to "Meilisearch".
|
46
|
+
RENAMED_MODULE_WARNING
|
47
|
+
|
48
|
+
@warned = true
|
49
|
+
end
|
50
|
+
end
|
16
51
|
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.
|
4
|
+
version: 0.31.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meili
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0.
|
19
|
+
version: '0.22'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0.
|
26
|
+
version: '0.22'
|
27
27
|
description: An easy-to-use ruby client for Meilisearch API. See https://github.com/meilisearch/meilisearch
|
28
28
|
email: bonjour@meilisearch.com
|
29
29
|
executables: []
|