meilisearch 0.25.1 → 0.27.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 +2 -2
- data/lib/meilisearch/client.rb +6 -0
- data/lib/meilisearch/error.rb +23 -16
- data/lib/meilisearch/index.rb +67 -0
- data/lib/meilisearch/utils.rb +1 -1
- data/lib/meilisearch/version.rb +1 -1
- metadata +6 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41cfeec247ef2cdaef19f6ddade5d32b7dcc80cbc69fe500c9310f7dab87e5a4
|
4
|
+
data.tar.gz: af889a896d762a38fbb1af56aba3b462cf73f35e4fe97048ef09bbaad44ffa53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ce24688fe857e840d07efda981cc00d0f8a60982aea1d487646b21a82117693eaa61fbe9dc778512b00b7d2363001c68dca0387f7b7a550a00eee022133c046
|
7
|
+
data.tar.gz: fda38ae00c08ba533e76dc0ce9a101331b23fb47e6c9554478a6027f1524b92141c6ecc764dce974402e66db67b9e6d85a96ff74893eb3419d0a9f02865b1cec
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -30,7 +30,7 @@
|
|
30
30
|
|
31
31
|
**Meilisearch** is an open-source search engine. [Learn more about Meilisearch.](https://github.com/meilisearch/meilisearch)
|
32
32
|
|
33
|
-
## Table of Contents <!-- omit in
|
33
|
+
## Table of Contents <!-- omit in TOC -->
|
34
34
|
|
35
35
|
- [📖 Documentation](#-documentation)
|
36
36
|
- [⚡ Supercharge your Meilisearch experience](#-supercharge-your-meilisearch-experience)
|
@@ -53,7 +53,7 @@ Say goodbye to server deployment and manual updates with [Meilisearch Cloud](htt
|
|
53
53
|
|
54
54
|
## 🔧 Installation
|
55
55
|
|
56
|
-
This package requires Ruby version
|
56
|
+
This package requires Ruby version 3.0.0 or later.
|
57
57
|
|
58
58
|
With `gem` in command line:
|
59
59
|
```bash
|
data/lib/meilisearch/client.rb
CHANGED
data/lib/meilisearch/error.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module MeiliSearch
|
4
|
-
class
|
4
|
+
class Error < StandardError
|
5
|
+
end
|
6
|
+
|
7
|
+
class ApiError < Error
|
5
8
|
# :http_code # e.g. 400, 404...
|
6
9
|
# :http_message # e.g. Bad Request, Not Found...
|
7
10
|
# :http_body # The response body received from the MeiliSearch API
|
@@ -18,26 +21,30 @@ module MeiliSearch
|
|
18
21
|
alias link ms_link
|
19
22
|
|
20
23
|
def initialize(http_code, http_message, http_body)
|
21
|
-
get_meilisearch_error_info(http_body) unless http_body.nil? || http_body.empty?
|
22
24
|
@http_code = http_code
|
23
25
|
@http_message = http_message
|
24
|
-
@
|
25
|
-
@
|
26
|
+
@http_body = parse_body(http_body)
|
27
|
+
@ms_code = @http_body['code']
|
28
|
+
@ms_type = @http_body['type']
|
29
|
+
@ms_message = @http_body.fetch('message', 'MeiliSearch API has not returned any error message')
|
30
|
+
@ms_link = @http_body.fetch('link', '<no documentation link found>')
|
26
31
|
@message = "#{http_code} #{http_message} - #{@ms_message}. See #{ms_link}."
|
27
32
|
super(details)
|
28
33
|
end
|
29
34
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
def parse_body(http_body)
|
36
|
+
if http_body.respond_to?(:to_hash)
|
37
|
+
http_body.to_hash
|
38
|
+
elsif http_body.respond_to?(:to_str)
|
39
|
+
JSON.parse(http_body.to_str)
|
40
|
+
else
|
41
|
+
{}
|
42
|
+
end
|
36
43
|
rescue JSON::ParserError
|
37
44
|
# We might receive a JSON::ParserError when, for example, MeiliSearch is running behind
|
38
45
|
# some proxy (ELB or Nginx, for example), and the request timeouts, returning us
|
39
46
|
# a raw HTML body instead of a JSON as we were expecting
|
40
|
-
|
47
|
+
{ 'message' => "The server has not returned a valid JSON HTTP body: #{http_body}" }
|
41
48
|
end
|
42
49
|
|
43
50
|
def details
|
@@ -45,7 +52,7 @@ module MeiliSearch
|
|
45
52
|
end
|
46
53
|
end
|
47
54
|
|
48
|
-
class CommunicationError <
|
55
|
+
class CommunicationError < Error
|
49
56
|
attr_reader :message
|
50
57
|
|
51
58
|
def initialize(message)
|
@@ -54,7 +61,7 @@ module MeiliSearch
|
|
54
61
|
end
|
55
62
|
end
|
56
63
|
|
57
|
-
class TimeoutError <
|
64
|
+
class TimeoutError < Error
|
58
65
|
attr_reader :message
|
59
66
|
|
60
67
|
def initialize(message = nil)
|
@@ -64,8 +71,8 @@ module MeiliSearch
|
|
64
71
|
end
|
65
72
|
|
66
73
|
module TenantToken
|
67
|
-
class ExpireOrInvalidSignature <
|
68
|
-
class InvalidApiKey <
|
69
|
-
class InvalidSearchRules <
|
74
|
+
class ExpireOrInvalidSignature < MeiliSearch::Error; end
|
75
|
+
class InvalidApiKey < MeiliSearch::Error; end
|
76
|
+
class InvalidSearchRules < MeiliSearch::Error; end
|
70
77
|
end
|
71
78
|
end
|
data/lib/meilisearch/index.rb
CHANGED
@@ -234,6 +234,15 @@ module MeiliSearch
|
|
234
234
|
response
|
235
235
|
end
|
236
236
|
|
237
|
+
### FACET SEARCH
|
238
|
+
|
239
|
+
def facet_search(name, query = '', **options)
|
240
|
+
options.merge!(facet_name: name, facet_query: query)
|
241
|
+
options = Utils.transform_attributes(options)
|
242
|
+
|
243
|
+
http_post("/indexes/#{@uid}/facet-search", options)
|
244
|
+
end
|
245
|
+
|
237
246
|
### TASKS
|
238
247
|
|
239
248
|
def task_endpoint
|
@@ -461,5 +470,63 @@ module MeiliSearch
|
|
461
470
|
def reset_faceting
|
462
471
|
http_delete("/indexes/#{@uid}/settings/faceting")
|
463
472
|
end
|
473
|
+
|
474
|
+
### SETTINGS - DICTIONARY
|
475
|
+
|
476
|
+
def dictionary
|
477
|
+
http_get("/indexes/#{@uid}/settings/dictionary")
|
478
|
+
end
|
479
|
+
|
480
|
+
def update_dictionary(dictionary_attributes)
|
481
|
+
attributes = Utils.transform_attributes(dictionary_attributes)
|
482
|
+
http_put("/indexes/#{@uid}/settings/dictionary", attributes)
|
483
|
+
end
|
484
|
+
|
485
|
+
def reset_dictionary
|
486
|
+
http_delete("/indexes/#{@uid}/settings/dictionary")
|
487
|
+
end
|
488
|
+
### SETTINGS - SEPARATOR TOKENS
|
489
|
+
|
490
|
+
def separator_tokens
|
491
|
+
http_get("/indexes/#{@uid}/settings/separator-tokens")
|
492
|
+
end
|
493
|
+
|
494
|
+
def update_separator_tokens(separator_tokens_attributes)
|
495
|
+
attributes = Utils.transform_attributes(separator_tokens_attributes)
|
496
|
+
http_put("/indexes/#{@uid}/settings/separator-tokens", attributes)
|
497
|
+
end
|
498
|
+
|
499
|
+
def reset_separator_tokens
|
500
|
+
http_delete("/indexes/#{@uid}/settings/separator-tokens")
|
501
|
+
end
|
502
|
+
|
503
|
+
### SETTINGS - NON SEPARATOR TOKENS
|
504
|
+
|
505
|
+
def non_separator_tokens
|
506
|
+
http_get("/indexes/#{@uid}/settings/non-separator-tokens")
|
507
|
+
end
|
508
|
+
|
509
|
+
def update_non_separator_tokens(non_separator_tokens_attributes)
|
510
|
+
attributes = Utils.transform_attributes(non_separator_tokens_attributes)
|
511
|
+
http_put("/indexes/#{@uid}/settings/non-separator-tokens", attributes)
|
512
|
+
end
|
513
|
+
|
514
|
+
def reset_non_separator_tokens
|
515
|
+
http_delete("/indexes/#{@uid}/settings/non-separator-tokens")
|
516
|
+
end
|
517
|
+
|
518
|
+
### SETTINGS - PROXIMITY PRECISION
|
519
|
+
|
520
|
+
def proximity_precision
|
521
|
+
http_get("/indexes/#{@uid}/settings/proximity-precision")
|
522
|
+
end
|
523
|
+
|
524
|
+
def update_proximity_precision(proximity_precision_attribute)
|
525
|
+
http_put("/indexes/#{@uid}/settings/proximity-precision", proximity_precision_attribute)
|
526
|
+
end
|
527
|
+
|
528
|
+
def reset_proximity_precision
|
529
|
+
http_delete("/indexes/#{@uid}/settings/proximity-precision")
|
530
|
+
end
|
464
531
|
end
|
465
532
|
end
|
data/lib/meilisearch/utils.rb
CHANGED
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.27.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: 2024-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -51,7 +51,8 @@ files:
|
|
51
51
|
homepage: https://github.com/meilisearch/meilisearch-ruby
|
52
52
|
licenses:
|
53
53
|
- MIT
|
54
|
-
metadata:
|
54
|
+
metadata:
|
55
|
+
rubygems_mfa_required: 'true'
|
55
56
|
post_install_message:
|
56
57
|
rdoc_options: []
|
57
58
|
require_paths:
|
@@ -60,14 +61,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
60
61
|
requirements:
|
61
62
|
- - ">="
|
62
63
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
64
|
+
version: 3.0.0
|
64
65
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
66
|
requirements:
|
66
67
|
- - ">="
|
67
68
|
- !ruby/object:Gem::Version
|
68
69
|
version: '0'
|
69
70
|
requirements: []
|
70
|
-
rubygems_version: 3.
|
71
|
+
rubygems_version: 3.2.33
|
71
72
|
signing_key:
|
72
73
|
specification_version: 4
|
73
74
|
summary: An easy-to-use ruby client for Meilisearch API
|