meilisearch 0.18.0 → 0.18.1
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/README.md +18 -18
- data/lib/meilisearch/http_request.rb +49 -45
- data/lib/meilisearch/index.rb +1 -1
- data/lib/meilisearch/version.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6309d55fa663d9fd8126c1bbf290313ddab29e0e8e72ee690b0abe49887d6097
|
4
|
+
data.tar.gz: 2386993d60f7fa52c38e10d58e191a0f0797a3672de31a36b5c1013440285584
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d50aa62ffebcd4d707fc55471e8738d9dd53433c77af3f1bb08e3681395ee19eb35513bc14a1e769bf223a9e16622805dc1010d06b4b84c2252237d1eb5a8b97
|
7
|
+
data.tar.gz: fff2a910e52b6c137037c3b011ddba3b0d11d28fd2427c1b4d45e925e2b28711c4e0fca269309de9b97dd99df980e4ed067b322c7148c0fde68a14ce4fe7d388
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
<p align="center">
|
2
|
-
<img src="https://
|
2
|
+
<img src="https://raw.githubusercontent.com/meilisearch/integration-guides/main/assets/logos/meilisearch_ruby.svg" alt="Meilisearch-Ruby" width="200" height="200" />
|
3
3
|
</p>
|
4
4
|
|
5
|
-
<h1 align="center">
|
5
|
+
<h1 align="center">Meilisearch Ruby</h1>
|
6
6
|
|
7
7
|
<h4 align="center">
|
8
|
-
<a href="https://github.com/meilisearch/
|
8
|
+
<a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> |
|
9
9
|
<a href="https://docs.meilisearch.com">Documentation</a> |
|
10
10
|
<a href="https://slack.meilisearch.com">Slack</a> |
|
11
11
|
<a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
|
@@ -20,18 +20,18 @@
|
|
20
20
|
<a href="https://ms-bors.herokuapp.com/repositories/6"><img src="https://bors.tech/images/badge_small.svg" alt="Bors enabled"></a>
|
21
21
|
</p>
|
22
22
|
|
23
|
-
<p align="center">⚡ The
|
23
|
+
<p align="center">⚡ The Meilisearch API client written for Ruby 💎</p>
|
24
24
|
|
25
|
-
**
|
25
|
+
**Meilisearch Ruby** is the Meilisearch API client for Ruby developers.
|
26
26
|
|
27
|
-
**
|
27
|
+
**Meilisearch** is an open-source search engine. [Discover what Meilisearch is!](https://github.com/meilisearch/meilisearch)
|
28
28
|
|
29
29
|
## Table of Contents <!-- omit in toc -->
|
30
30
|
|
31
31
|
- [📖 Documentation](#-documentation)
|
32
32
|
- [🔧 Installation](#-installation)
|
33
33
|
- [🚀 Getting Started](#-getting-started)
|
34
|
-
- [🤖 Compatibility with
|
34
|
+
- [🤖 Compatibility with Meilisearch](#-compatibility-with-meilisearch)
|
35
35
|
- [💡 Learn More](#-learn-more)
|
36
36
|
- [⚙️ Development Workflow and Contributing](#️-development-workflow-and-contributing)
|
37
37
|
|
@@ -55,21 +55,21 @@ source 'https://rubygems.org'
|
|
55
55
|
gem 'meilisearch'
|
56
56
|
```
|
57
57
|
|
58
|
-
### Run
|
58
|
+
### Run Meilisearch <!-- omit in toc -->
|
59
59
|
|
60
|
-
There are many easy ways to [download and run a
|
60
|
+
There are many easy ways to [download and run a Meilisearch instance](https://docs.meilisearch.com/reference/features/installation.html#download-and-launch).
|
61
61
|
|
62
62
|
For example, using the `curl` command in your [Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/web-publishing/what-is-a-terminal/):
|
63
63
|
|
64
64
|
```sh
|
65
|
-
#Install
|
65
|
+
#Install Meilisearch
|
66
66
|
curl -L https://install.meilisearch.com | sh
|
67
67
|
|
68
|
-
# Launch
|
68
|
+
# Launch Meilisearch
|
69
69
|
./meilisearch --master-key=masterKey
|
70
70
|
```
|
71
71
|
|
72
|
-
NB: you can also download
|
72
|
+
NB: you can also download Meilisearch from **Homebrew** or **APT** or even run it using **Docker**.
|
73
73
|
|
74
74
|
## 🚀 Getting Started
|
75
75
|
|
@@ -91,7 +91,7 @@ documents = [
|
|
91
91
|
{ id: 5, title: 'Moana', genres: ['Fantasy', 'Action']},
|
92
92
|
{ id: 6, title: 'Philadelphia', genres: ['Drama'] },
|
93
93
|
]
|
94
|
-
# If the index 'movies' does not exist,
|
94
|
+
# If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
|
95
95
|
index.add_documents(documents) # => { "uid": 0 }
|
96
96
|
```
|
97
97
|
|
@@ -102,7 +102,7 @@ With the `uid`, you can check the status (`enqueued`, `processing`, `succeeded`
|
|
102
102
|
#### Basic Search <!-- omit in toc -->
|
103
103
|
|
104
104
|
``` ruby
|
105
|
-
#
|
105
|
+
# Meilisearch is typo-tolerant:
|
106
106
|
puts index.search('carlo')
|
107
107
|
```
|
108
108
|
Output:
|
@@ -165,7 +165,7 @@ index.update_filterable_attributes([
|
|
165
165
|
|
166
166
|
You only need to perform this operation once.
|
167
167
|
|
168
|
-
Note that
|
168
|
+
Note that Meilisearch will rebuild your index whenever you update `filterableAttributes`. Depending on the size of your dataset, this might take time. You can track the process using the [tasks](https://docs.meilisearch.com/reference/api/tasks.html#get-task)).
|
169
169
|
|
170
170
|
Then, you can perform the search:
|
171
171
|
|
@@ -196,9 +196,9 @@ JSON output:
|
|
196
196
|
}
|
197
197
|
```
|
198
198
|
|
199
|
-
## 🤖 Compatibility with
|
199
|
+
## 🤖 Compatibility with Meilisearch
|
200
200
|
|
201
|
-
This package only guarantees the compatibility with the [version v0.25.0 of
|
201
|
+
This package only guarantees the compatibility with the [version v0.25.0 of Meilisearch](https://github.com/meilisearch/meilisearch/releases/tag/v0.25.0).
|
202
202
|
|
203
203
|
## 💡 Learn More
|
204
204
|
|
@@ -219,4 +219,4 @@ If you want to know more about the development workflow or want to contribute, p
|
|
219
219
|
|
220
220
|
<hr>
|
221
221
|
|
222
|
-
**
|
222
|
+
**Meilisearch** provides and maintains many **SDKs and Integration tools** like this one. We want to provide everyone with an **amazing search experience for any kind of project**. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the [integration-guides](https://github.com/meilisearch/integration-guides) repository.
|
@@ -7,25 +7,30 @@ module MeiliSearch
|
|
7
7
|
class HTTPRequest
|
8
8
|
include HTTParty
|
9
9
|
|
10
|
-
attr_reader :options
|
10
|
+
attr_reader :options, :headers
|
11
|
+
|
12
|
+
DEFAULT_OPTIONS = {
|
13
|
+
timeout: 1,
|
14
|
+
max_retries: 0,
|
15
|
+
convert_body?: true
|
16
|
+
}.freeze
|
11
17
|
|
12
18
|
def initialize(url, api_key = nil, options = {})
|
13
19
|
@base_url = url
|
14
20
|
@api_key = api_key
|
15
|
-
@options =
|
16
|
-
|
17
|
-
max_retries: 0,
|
18
|
-
headers: build_default_options_headers(api_key),
|
19
|
-
convert_body?: true
|
20
|
-
}, options)
|
21
|
+
@options = DEFAULT_OPTIONS.merge(options)
|
22
|
+
@headers = build_default_options_headers
|
21
23
|
end
|
22
24
|
|
23
25
|
def http_get(relative_path = '', query_params = {})
|
24
26
|
send_request(
|
25
27
|
proc { |path, config| self.class.get(path, config) },
|
26
28
|
relative_path,
|
27
|
-
|
28
|
-
|
29
|
+
config: {
|
30
|
+
query_params: query_params,
|
31
|
+
headers: remove_headers(@headers.dup, 'Content-Type'),
|
32
|
+
options: @options
|
33
|
+
}
|
29
34
|
)
|
30
35
|
end
|
31
36
|
|
@@ -33,9 +38,12 @@ module MeiliSearch
|
|
33
38
|
send_request(
|
34
39
|
proc { |path, config| self.class.post(path, config) },
|
35
40
|
relative_path,
|
36
|
-
|
37
|
-
|
38
|
-
|
41
|
+
config: {
|
42
|
+
query_params: query_params,
|
43
|
+
body: body,
|
44
|
+
headers: @headers.dup.merge(options[:headers] || {}),
|
45
|
+
options: @options.merge(options)
|
46
|
+
}
|
39
47
|
)
|
40
48
|
end
|
41
49
|
|
@@ -43,9 +51,12 @@ module MeiliSearch
|
|
43
51
|
send_request(
|
44
52
|
proc { |path, config| self.class.put(path, config) },
|
45
53
|
relative_path,
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
config: {
|
55
|
+
query_params: query_params,
|
56
|
+
body: body,
|
57
|
+
headers: @headers,
|
58
|
+
options: @options
|
59
|
+
}
|
49
60
|
)
|
50
61
|
end
|
51
62
|
|
@@ -53,9 +64,12 @@ module MeiliSearch
|
|
53
64
|
send_request(
|
54
65
|
proc { |path, config| self.class.patch(path, config) },
|
55
66
|
relative_path,
|
56
|
-
|
57
|
-
|
58
|
-
|
67
|
+
config: {
|
68
|
+
query_params: query_params,
|
69
|
+
body: body,
|
70
|
+
headers: @headers,
|
71
|
+
options: @options
|
72
|
+
}
|
59
73
|
)
|
60
74
|
end
|
61
75
|
|
@@ -63,53 +77,43 @@ module MeiliSearch
|
|
63
77
|
send_request(
|
64
78
|
proc { |path, config| self.class.delete(path, config) },
|
65
79
|
relative_path,
|
66
|
-
|
80
|
+
config: {
|
81
|
+
headers: remove_headers(@headers.dup, 'Content-Type'),
|
82
|
+
options: @options
|
83
|
+
}
|
67
84
|
)
|
68
85
|
end
|
69
86
|
|
70
87
|
private
|
71
88
|
|
72
|
-
def build_default_options_headers
|
73
|
-
|
74
|
-
'Content-Type' => 'application/json'
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
79
|
-
|
80
|
-
def merge_options(default_options, added_options = {})
|
81
|
-
default_cloned_headers = default_options[:headers].clone
|
82
|
-
merged_options = default_options.merge(added_options)
|
83
|
-
merged_options[:headers] = default_cloned_headers.merge(added_options[:headers]) if added_options.key?(:headers)
|
84
|
-
merged_options
|
89
|
+
def build_default_options_headers
|
90
|
+
{
|
91
|
+
'Content-Type' => 'application/json',
|
92
|
+
'Authorization' => ("Bearer #{@api_key}" unless @api_key.nil?),
|
93
|
+
'User-Agent' => MeiliSearch.qualified_version
|
94
|
+
}.compact
|
85
95
|
end
|
86
96
|
|
87
|
-
def
|
88
|
-
|
89
|
-
cloned_options[:headers].tap { |headers| headers.delete(key) }
|
90
|
-
cloned_options
|
97
|
+
def remove_headers(data, *keys)
|
98
|
+
data.delete_if { |k| keys.include?(k) }
|
91
99
|
end
|
92
100
|
|
93
|
-
def
|
94
|
-
|
95
|
-
cloned_options[:headers] = options[:headers].clone
|
96
|
-
cloned_options
|
97
|
-
end
|
101
|
+
def send_request(http_method, relative_path, config: {})
|
102
|
+
config = http_config(config[:query_params], config[:body], config[:options], config[:headers])
|
98
103
|
|
99
|
-
def send_request(http_method, relative_path, query_params: nil, body: nil, options: {})
|
100
|
-
config = http_config(query_params, body, options)
|
101
104
|
begin
|
102
105
|
response = http_method.call(@base_url + relative_path, config)
|
103
106
|
rescue Errno::ECONNREFUSED => e
|
104
107
|
raise CommunicationError, e.message
|
105
108
|
end
|
109
|
+
|
106
110
|
validate(response)
|
107
111
|
end
|
108
112
|
|
109
|
-
def http_config(query_params, body, options)
|
113
|
+
def http_config(query_params, body, options, headers)
|
110
114
|
body = body.to_json if options[:convert_body?] == true
|
111
115
|
{
|
112
|
-
headers:
|
116
|
+
headers: headers,
|
113
117
|
query: query_params,
|
114
118
|
body: body,
|
115
119
|
timeout: options[:timeout],
|
data/lib/meilisearch/index.rb
CHANGED
@@ -81,7 +81,7 @@ module MeiliSearch
|
|
81
81
|
alias add_or_replace_documents! add_documents!
|
82
82
|
|
83
83
|
def add_documents_json(documents, primary_key = nil)
|
84
|
-
options = {
|
84
|
+
options = { convert_body?: false }
|
85
85
|
http_post "/indexes/#{@uid}/documents", documents, { primaryKey: primary_key }.compact, options
|
86
86
|
end
|
87
87
|
alias replace_documents_json add_documents_json
|
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.18.
|
4
|
+
version: 0.18.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meili
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-01
|
11
|
+
date: 2022-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 0.21.0
|
33
|
-
description: An easy-to-use ruby client for Meilisearch API. See https://github.com/meilisearch/
|
33
|
+
description: An easy-to-use ruby client for Meilisearch API. See https://github.com/meilisearch/meilisearch
|
34
34
|
email: bonjour@meilisearch.com
|
35
35
|
executables: []
|
36
36
|
extensions: []
|