meilisearch 0.23.0 → 0.24.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/README.md +7 -7
- data/lib/meilisearch/index.rb +35 -6
- data/lib/meilisearch/utils.rb +21 -2
- data/lib/meilisearch/version.rb +1 -1
- 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: a6fbd8b345ade69adfd322c7cf10e0e1acca19ecdbf84eb0ef7f04b8ce2ec810
|
4
|
+
data.tar.gz: 88c9635e0310e89f3a793a7ff39741e49c88f1bcf7f9916c2f2873642dd329d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d674d11207d8f829d132996f01a2f6ed59da3f79d004c518df6d1ec73c8c7f966b5179da373a90d00073dc813a2cd3a74cb46efb6212b5dc3958fe2b7c27118
|
7
|
+
data.tar.gz: d5912112b1a69edafff5825d63d488d6d0ffc7106c7ec807d992f1eef9e7c0f6a635b54fe3b716afe6d372fad95cce10bcac4231ba233ec07a839e7ebc8e14f0
|
data/README.md
CHANGED
@@ -60,12 +60,12 @@ gem 'meilisearch'
|
|
60
60
|
|
61
61
|
### Run Meilisearch <!-- omit in toc -->
|
62
62
|
|
63
|
-
There are many easy ways to [download and run a Meilisearch instance](https://docs.meilisearch.com/
|
63
|
+
There are many easy ways to [download and run a Meilisearch instance](https://docs.meilisearch.com/learn/getting_started/quick_start.html#setup-and-installation).
|
64
64
|
|
65
|
-
For example, using the `curl` command in your [Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/
|
65
|
+
For example, using the `curl` command in your [Terminal](https://itconnect.uw.edu/learn/workshops/online-tutorials/what-is-a-terminal/):
|
66
66
|
|
67
67
|
```sh
|
68
|
-
#Install Meilisearch
|
68
|
+
# Install Meilisearch
|
69
69
|
curl -L https://install.meilisearch.com | sh
|
70
70
|
|
71
71
|
# Launch Meilisearch
|
@@ -98,7 +98,7 @@ documents = [
|
|
98
98
|
index.add_documents(documents) # => { "uid": 0 }
|
99
99
|
```
|
100
100
|
|
101
|
-
With the `uid`, you can check the status (`enqueued`, `processing`, `succeeded` or `failed`) of your documents addition using the [task](https://docs.meilisearch.com/reference/api/tasks.html#get-
|
101
|
+
With the `uid`, you can check the status (`enqueued`, `processing`, `succeeded` or `failed`) of your documents addition using the [task](https://docs.meilisearch.com/reference/api/tasks.html#get-tasks).
|
102
102
|
|
103
103
|
💡 To customize the `Client`, for example, increasing the default timeout, please check out [this section](https://github.com/meilisearch/meilisearch-ruby/wiki/Client-Options) of the Wiki.
|
104
104
|
|
@@ -125,7 +125,7 @@ Output:
|
|
125
125
|
|
126
126
|
#### Custom search <!-- omit in toc -->
|
127
127
|
|
128
|
-
All the supported options are described in the [search parameters](https://docs.meilisearch.com/reference/
|
128
|
+
All the supported options are described in the [search parameters](https://docs.meilisearch.com/reference/api/search.html#search-parameters) section of the documentation.
|
129
129
|
|
130
130
|
```ruby
|
131
131
|
index.search(
|
@@ -168,7 +168,7 @@ index.update_filterable_attributes([
|
|
168
168
|
|
169
169
|
You only need to perform this operation once.
|
170
170
|
|
171
|
-
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-
|
171
|
+
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-tasks)).
|
172
172
|
|
173
173
|
Then, you can perform the search:
|
174
174
|
|
@@ -207,7 +207,7 @@ This package guarantees compatibility with [version v1.x of Meilisearch](https:/
|
|
207
207
|
The following sections in our main documentation website may interest you:
|
208
208
|
|
209
209
|
- **Manipulate documents**: see the [API references](https://docs.meilisearch.com/reference/api/documents.html) or read more about [documents](https://docs.meilisearch.com/learn/core_concepts/documents.html).
|
210
|
-
- **Search**: see the [API references](https://docs.meilisearch.com/reference/api/search.html) or follow our guide on [search parameters](https://docs.meilisearch.com/reference/
|
210
|
+
- **Search**: see the [API references](https://docs.meilisearch.com/reference/api/search.html) or follow our guide on [search parameters](https://docs.meilisearch.com/reference/api/search.html#search-parameters).
|
211
211
|
- **Manage the indexes**: see the [API references](https://docs.meilisearch.com/reference/api/indexes.html) or read more about [indexes](https://docs.meilisearch.com/learn/core_concepts/indexes.html).
|
212
212
|
- **Configure the index settings**: see the [API references](https://docs.meilisearch.com/reference/api/settings.html) or follow our guide on [settings parameters](https://docs.meilisearch.com/reference/features/settings.html).
|
213
213
|
|
data/lib/meilisearch/index.rb
CHANGED
@@ -63,8 +63,24 @@ module MeiliSearch
|
|
63
63
|
alias get_document document
|
64
64
|
alias get_one_document document
|
65
65
|
|
66
|
+
# Public: Retrieve documents from a index.
|
67
|
+
#
|
68
|
+
# options - The hash options used to refine the selection (default: {}):
|
69
|
+
# :limit - Number of documents to return (optional).
|
70
|
+
# :offset - Number of documents to skip (optional).
|
71
|
+
# :fields - Array of document attributes to show (optional).
|
72
|
+
# :filter - Filter queries by an attribute's value.
|
73
|
+
# Available ONLY with Meilisearch v1.2 and newer (optional).
|
74
|
+
#
|
75
|
+
# Returns the documents results object.
|
66
76
|
def documents(options = {})
|
67
|
-
|
77
|
+
Utils.version_error_handler(__method__) do
|
78
|
+
if options.key?(:filter)
|
79
|
+
http_post "/indexes/#{@uid}/documents/fetch", Utils.filter(options, [:limit, :offset, :fields, :filter])
|
80
|
+
else
|
81
|
+
http_get "/indexes/#{@uid}/documents", Utils.parse_query(options, [:limit, :offset, :fields])
|
82
|
+
end
|
83
|
+
end
|
68
84
|
end
|
69
85
|
alias get_documents documents
|
70
86
|
|
@@ -153,11 +169,24 @@ module MeiliSearch
|
|
153
169
|
responses
|
154
170
|
end
|
155
171
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
172
|
+
# Public: Delete documents from an index
|
173
|
+
#
|
174
|
+
# options: A Hash or an Array containing documents_ids or a hash with filter:.
|
175
|
+
# filter: - A hash containing a filter that should match documents.
|
176
|
+
# Available ONLY with Meilisearch v1.2 and newer (optional)
|
177
|
+
#
|
178
|
+
# Returns a Task object.
|
179
|
+
def delete_documents(options = {})
|
180
|
+
Utils.version_error_handler(__method__) do
|
181
|
+
if options.is_a?(Hash) && options.key?(:filter)
|
182
|
+
http_post "/indexes/#{@uid}/documents/delete", options
|
183
|
+
else
|
184
|
+
# backwards compatibility:
|
185
|
+
# expect to be a array or/number/string to send alongside as documents_ids.
|
186
|
+
options = [options] unless options.is_a?(Array)
|
187
|
+
|
188
|
+
http_post "/indexes/#{@uid}/documents/delete-batch", options
|
189
|
+
end
|
161
190
|
end
|
162
191
|
end
|
163
192
|
alias delete_multiple_documents delete_documents
|
data/lib/meilisearch/utils.rb
CHANGED
@@ -23,8 +23,12 @@ module MeiliSearch
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.filter(original_options, allowed_params = [])
|
27
|
+
original_options.transform_keys(&:to_sym).slice(*allowed_params)
|
28
|
+
end
|
29
|
+
|
26
30
|
def self.parse_query(original_options, allowed_params = [])
|
27
|
-
only_allowed_params = original_options
|
31
|
+
only_allowed_params = filter(original_options, allowed_params)
|
28
32
|
|
29
33
|
Utils.transform_attributes(only_allowed_params).then do |body|
|
30
34
|
body.transform_values do |v|
|
@@ -33,6 +37,21 @@ module MeiliSearch
|
|
33
37
|
end
|
34
38
|
end
|
35
39
|
|
36
|
-
|
40
|
+
def self.message_builder(current_message, method_name)
|
41
|
+
"#{current_message}\nHint: It might not be working because maybe you're not up " \
|
42
|
+
"to date with the Meilisearch version that `#{method_name}` call requires."
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.version_error_handler(method_name)
|
46
|
+
yield if block_given?
|
47
|
+
rescue MeiliSearch::ApiError => e
|
48
|
+
message = message_builder(e.http_message, method_name)
|
49
|
+
|
50
|
+
raise MeiliSearch::ApiError.new(e.http_code, message, e.http_body)
|
51
|
+
rescue StandardError => e
|
52
|
+
raise e.class, message_builder(e.message, method_name)
|
53
|
+
end
|
54
|
+
|
55
|
+
private_class_method :parse, :message_builder
|
37
56
|
end
|
38
57
|
end
|
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.24.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Meili
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|