meilisearch-rails 0.8.0 → 0.9.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 +10 -2
- data/lib/meilisearch/rails/version.rb +1 -1
- data/lib/meilisearch-rails.rb +16 -9
- data/meilisearch-rails.gemspec +1 -1
- 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: 25c4de2cc918a39c265d31b9191302e42e66a80f1b9d4b9e07c89074bb9e8eec
|
4
|
+
data.tar.gz: d6572c3e463044c8401d0916aed8c396ac7559e980e5be03ba874af9d10ab54b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf2356509509b70d9ebe00715faa680cd76b58802643712f5447d8d2de93aaae934f7b0048da2eaeb69fcee549654d5e80e24be5a5e71ee2a92c3b5a2c6a5280
|
7
|
+
data.tar.gz: 1f99790e054f917bc3c79df3eacb0471e7883dd414a8e03631d1382ef9b186eb53dffb2c1178e4625577231a03534c9348c4114f93b80655e9f242c60bf94de4
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<h4 align="center">
|
8
8
|
<a href="https://github.com/meilisearch/meilisearch">Meilisearch</a> |
|
9
9
|
<a href="https://docs.meilisearch.com">Documentation</a> |
|
10
|
-
<a href="https://
|
10
|
+
<a href="https://discord.meilisearch.com">Discord</a> |
|
11
11
|
<a href="https://roadmap.meilisearch.com/tabs/1-under-consideration">Roadmap</a> |
|
12
12
|
<a href="https://www.meilisearch.com">Website</a> |
|
13
13
|
<a href="https://docs.meilisearch.com/faq">FAQ</a>
|
@@ -62,7 +62,7 @@ To learn more about Meilisearch, check out our [Documentation](https://docs.meil
|
|
62
62
|
|
63
63
|
## 🤖 Compatibility with Meilisearch
|
64
64
|
|
65
|
-
This package
|
65
|
+
This package guarantees compatibility with [version v1.x of Meilisearch](https://github.com/meilisearch/meilisearch/releases/latest), but some features may not be present. Please check the [issues](https://github.com/meilisearch/meilisearch-rails/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22+label%3Aenhancement) for more info.
|
66
66
|
|
67
67
|
## 🔧 Installation <!-- omit in toc -->
|
68
68
|
|
@@ -185,6 +185,7 @@ class Book < ApplicationRecord
|
|
185
185
|
attributes_to_highlight ['*']
|
186
186
|
attributes_to_crop [:description]
|
187
187
|
crop_length 10
|
188
|
+
faceting max_values_per_facet: 2000
|
188
189
|
pagination max_total_hits: 1000
|
189
190
|
end
|
190
191
|
end
|
@@ -199,6 +200,13 @@ All the supported options are described in the [search parameters](https://docs.
|
|
199
200
|
```ruby
|
200
201
|
Book.search('Harry', attributes_to_highlight: ['*'])
|
201
202
|
```
|
203
|
+
|
204
|
+
Then it's possible to retrieve the highlighted or cropped value by using the `formatted` method available in the object.
|
205
|
+
|
206
|
+
```ruby
|
207
|
+
harry_book.formatted # => {"id"=>"1", "name"=>"<em>Harry</em> Potter", "description"=>…
|
208
|
+
```
|
209
|
+
|
202
210
|
👉 Don't forget that `attributes_to_highlight`, `attributes_to_crop`, and
|
203
211
|
`crop_length` can be set up in the `meilisearch` block of your model.
|
204
212
|
|
data/lib/meilisearch-rails.rb
CHANGED
@@ -60,9 +60,11 @@ module MeiliSearch
|
|
60
60
|
attributesToCrop
|
61
61
|
cropLength
|
62
62
|
pagination
|
63
|
+
faceting
|
64
|
+
typoTolerance
|
63
65
|
].freeze
|
64
66
|
|
65
|
-
CAMELIZE_OPTIONS = %i[pagination].freeze
|
67
|
+
CAMELIZE_OPTIONS = %i[pagination faceting typoTolerance].freeze
|
66
68
|
|
67
69
|
OPTIONS.each do |option|
|
68
70
|
define_method option do |value|
|
@@ -198,6 +200,10 @@ module MeiliSearch
|
|
198
200
|
instance_variable_get("@#{name}")
|
199
201
|
end
|
200
202
|
|
203
|
+
def camelize_keys(hash)
|
204
|
+
hash.transform_keys { |key| key.to_s.camelize(:lower) }
|
205
|
+
end
|
206
|
+
|
201
207
|
def to_settings
|
202
208
|
settings = {}
|
203
209
|
OPTIONS.each do |k|
|
@@ -205,7 +211,12 @@ module MeiliSearch
|
|
205
211
|
next if v.nil?
|
206
212
|
|
207
213
|
settings[k] = if CAMELIZE_OPTIONS.include?(k) && v.is_a?(Hash)
|
208
|
-
v
|
214
|
+
v = camelize_keys(v)
|
215
|
+
|
216
|
+
# camelize keys of nested hashes
|
217
|
+
v.each do |key, value|
|
218
|
+
v[key] = camelize_keys(value) if value.is_a?(Hash)
|
219
|
+
end
|
209
220
|
else
|
210
221
|
v
|
211
222
|
end
|
@@ -587,13 +598,6 @@ module MeiliSearch
|
|
587
598
|
end
|
588
599
|
|
589
600
|
module AdditionalMethods
|
590
|
-
def self.extended(base)
|
591
|
-
class << base
|
592
|
-
alias_method :raw_answer, :ms_raw_answer unless method_defined? :raw_answer
|
593
|
-
alias_method :facets_distribution, :ms_facets_distribution unless method_defined? :facets_distribution
|
594
|
-
end
|
595
|
-
end
|
596
|
-
|
597
601
|
def ms_raw_answer
|
598
602
|
@ms_json
|
599
603
|
end
|
@@ -602,6 +606,9 @@ module MeiliSearch
|
|
602
606
|
@ms_json['facetDistribution']
|
603
607
|
end
|
604
608
|
|
609
|
+
alias raw_answer ms_raw_answer unless method_defined? :raw_answer
|
610
|
+
alias facets_distribution ms_facets_distribution unless method_defined? :facets_distribution
|
611
|
+
|
605
612
|
private
|
606
613
|
|
607
614
|
def ms_init_raw_answer(json)
|
data/meilisearch-rails.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: meilisearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.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: 2023-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: meilisearch
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.22.0
|
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.0
|
27
27
|
description: Meilisearch integration for Ruby on Rails. See https://github.com/meilisearch/meilisearch
|
28
28
|
email: bonjour@meilisearch.com
|
29
29
|
executables: []
|