meilisearch 0.29.0 → 0.30.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/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 +2 -2
- data/lib/meilisearch/index.rb +74 -2
- data/lib/meilisearch/models/task.rb +2 -2
- data/lib/meilisearch/multi_search.rb +1 -1
- 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 +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5efbe9d158037686df9b8bb37bf42e99646abeaae9bb8134a795507c84887c5d
|
4
|
+
data.tar.gz: 7552001f2cb4030e09588d0601e49ae0d82c5858a31ea491740374251bbf5fd8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea80d3871ada8d4dcf224893f38ad7a972500df85aabd9100c0772bc9e9aaf3fec9bafa408628357e9d802bfa445307307905b04d4edc656cb8c9808ea307382
|
7
|
+
data.tar.gz: 742c90c3cbc9d931bf30b7d2d533e1dc577404b55ae4a7f2646a88e2b5a2388eda1f70db742ac3acf44721f22a137c1f1c93adab4fb7287475350850c9fe1e9f
|
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
|
|
@@ -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
|
|
@@ -185,6 +185,18 @@ module MeiliSearch
|
|
185
185
|
update_documents_in_batches(documents, batch_size, primary_key).each(&:await)
|
186
186
|
end
|
187
187
|
|
188
|
+
# Update documents by function
|
189
|
+
#
|
190
|
+
# options - A Hash containing the function string and related options
|
191
|
+
# context:
|
192
|
+
# filter:
|
193
|
+
# function:
|
194
|
+
def update_documents_by_function(options)
|
195
|
+
response = http_post "/indexes/#{@uid}/documents/edit", options
|
196
|
+
|
197
|
+
Models::Task.new(response, task_endpoint)
|
198
|
+
end
|
199
|
+
|
188
200
|
# Public: Delete documents from an index
|
189
201
|
#
|
190
202
|
# options: A Hash or an Array containing documents_ids or a hash with filter:.
|
@@ -221,7 +233,7 @@ module MeiliSearch
|
|
221
233
|
|
222
234
|
def delete_document(document_id)
|
223
235
|
if document_id.nil? || document_id.to_s.empty?
|
224
|
-
raise
|
236
|
+
raise Meilisearch::InvalidDocumentId, 'document_id cannot be empty or nil'
|
225
237
|
end
|
226
238
|
|
227
239
|
encode_document = URI.encode_www_form_component(document_id)
|
@@ -617,5 +629,65 @@ module MeiliSearch
|
|
617
629
|
def reset_search_cutoff_ms
|
618
630
|
http_delete("/indexes/#{@uid}/settings/search-cutoff-ms")
|
619
631
|
end
|
632
|
+
|
633
|
+
### SETTINGS - LOCALIZED ATTRIBUTES
|
634
|
+
|
635
|
+
def localized_attributes
|
636
|
+
http_get("/indexes/#{@uid}/settings/localized-attributes")
|
637
|
+
end
|
638
|
+
|
639
|
+
def update_localized_attributes(new_localized_attributes)
|
640
|
+
new_localized_attributes = Utils.transform_attributes(new_localized_attributes)
|
641
|
+
|
642
|
+
http_put("/indexes/#{@uid}/settings/localized-attributes", new_localized_attributes)
|
643
|
+
end
|
644
|
+
|
645
|
+
def reset_localized_attributes
|
646
|
+
http_delete("/indexes/#{@uid}/settings/localized-attributes")
|
647
|
+
end
|
648
|
+
|
649
|
+
### SETTINGS - FACET SEARCH
|
650
|
+
|
651
|
+
def facet_search_setting
|
652
|
+
http_get("/indexes/#{@uid}/settings/facet-search")
|
653
|
+
end
|
654
|
+
|
655
|
+
def update_facet_search_setting(new_facet_search_setting)
|
656
|
+
http_put("/indexes/#{@uid}/settings/facet-search", new_facet_search_setting)
|
657
|
+
end
|
658
|
+
|
659
|
+
def reset_facet_search_setting
|
660
|
+
http_delete("/indexes/#{@uid}/settings/facet-search")
|
661
|
+
end
|
662
|
+
|
663
|
+
### SETTINGS - PREFIX SEARCH
|
664
|
+
|
665
|
+
def prefix_search
|
666
|
+
http_get("/indexes/#{@uid}/settings/prefix-search")
|
667
|
+
end
|
668
|
+
|
669
|
+
def update_prefix_search(new_prefix_search_setting)
|
670
|
+
http_put("/indexes/#{@uid}/settings/prefix-search", new_prefix_search_setting)
|
671
|
+
end
|
672
|
+
|
673
|
+
def reset_prefix_search
|
674
|
+
http_delete("/indexes/#{@uid}/settings/prefix-search")
|
675
|
+
end
|
676
|
+
|
677
|
+
### SETTINGS - EMBEDDERS
|
678
|
+
|
679
|
+
def embedders
|
680
|
+
http_get("/indexes/#{@uid}/settings/embedders")
|
681
|
+
end
|
682
|
+
|
683
|
+
def update_embedders(new_embedders)
|
684
|
+
new_embedders = Utils.transform_attributes(new_embedders)
|
685
|
+
|
686
|
+
http_patch("/indexes/#{@uid}/settings/embedders", new_embedders)
|
687
|
+
end
|
688
|
+
|
689
|
+
def reset_embedders
|
690
|
+
http_delete("/indexes/#{@uid}/settings/embedders")
|
691
|
+
end
|
620
692
|
end
|
621
693
|
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
|
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.30.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-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|