meilisearch-rails 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5533b797c2c1df4ba52eee7e73d68c81b8a329353b896d7e5d6b17560f2b9c6d
|
4
|
+
data.tar.gz: c65d9fc11a89d2d054392b44c8858b59429e84fc707f569ba7d3888c4685c0df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f86c37174ef35dce271cc4dbd0ef51355828e9c1bb16c266b019883afc7fb1856f73b4d6dd61982c74e41c716122684d7307a31ee86d0015b3538bbc3c3f6616
|
7
|
+
data.tar.gz: 88038b5cae1f6611e4793cf5051f03f88e9c01683bde793c38134340eb68126b38d3784b3e73bf7b79b07e0bbdf9d44d08c08938abee35b7a950728f6fc4c43b
|
data/README.md
CHANGED
@@ -110,11 +110,17 @@ Create a new file `config/initializers/meilisearch.rb` to setup your `MEILISEARC
|
|
110
110
|
|
111
111
|
```ruby
|
112
112
|
MeiliSearch::Rails.configuration = {
|
113
|
-
meilisearch_url: '
|
114
|
-
meilisearch_api_key: 'YourMeilisearchAPIKey'
|
113
|
+
meilisearch_url: ENV.fetch('MEILISEARCH_HOST', 'http://localhost:7700'),
|
114
|
+
meilisearch_api_key: ENV.fetch('MEILISEARCH_API_KEY', 'YourMeilisearchAPIKey')
|
115
115
|
}
|
116
116
|
```
|
117
117
|
|
118
|
+
Or you can run a rake task to create the initializer file for you:
|
119
|
+
|
120
|
+
```bash
|
121
|
+
bin/rails meilisearch:install
|
122
|
+
```
|
123
|
+
|
118
124
|
The gem is compatible with [ActiveRecord](https://github.com/rails/rails/tree/master/activerecord), [Mongoid](https://github.com/mongoid/mongoid) and [Sequel](https://github.com/jeremyevans/sequel).
|
119
125
|
|
120
126
|
⚠️ Note that even if you want to use all the default options, you must declare an empty `meilisearch` block in your model.
|
@@ -19,4 +19,11 @@ namespace :meilisearch do
|
|
19
19
|
|
20
20
|
MeiliSearch::Rails::Utilities.clear_all_indexes
|
21
21
|
end
|
22
|
+
|
23
|
+
desc 'Create initializer file'
|
24
|
+
task install: :environment do
|
25
|
+
puts 'Creating initializer file'
|
26
|
+
|
27
|
+
copy_file "#{__dir__}/../templates/initializer.rb", 'config/initializers/meilisearch.rb'
|
28
|
+
end
|
22
29
|
end
|
data/lib/meilisearch-rails.rb
CHANGED
@@ -48,23 +48,23 @@ module MeiliSearch
|
|
48
48
|
|
49
49
|
# Meilisearch settings
|
50
50
|
OPTIONS = %i[
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
searchable_attributes
|
52
|
+
filterable_attributes
|
53
|
+
sortable_attributes
|
54
|
+
displayed_attributes
|
55
|
+
distinct_attribute
|
56
56
|
synonyms
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
57
|
+
stop_words
|
58
|
+
ranking_rules
|
59
|
+
attributes_to_highlight
|
60
|
+
attributes_to_crop
|
61
|
+
crop_length
|
62
62
|
pagination
|
63
63
|
faceting
|
64
|
-
|
64
|
+
typo_tolerance
|
65
65
|
].freeze
|
66
66
|
|
67
|
-
CAMELIZE_OPTIONS = %i[pagination faceting
|
67
|
+
CAMELIZE_OPTIONS = %i[pagination faceting typo_tolerance].freeze
|
68
68
|
|
69
69
|
OPTIONS.each do |option|
|
70
70
|
define_method option do |value|
|
@@ -265,9 +265,9 @@ module MeiliSearch
|
|
265
265
|
::MeiliSearch::Index.instance_methods(false).each do |m|
|
266
266
|
define_method(m) do |*args, &block|
|
267
267
|
if m == :update_settings
|
268
|
-
args[0].delete(:
|
269
|
-
args[0].delete(:
|
270
|
-
args[0].delete(:
|
268
|
+
args[0].delete(:attributes_to_highlight) if args[0][:attributes_to_highlight]
|
269
|
+
args[0].delete(:attributes_to_crop) if args[0][:attributes_to_crop]
|
270
|
+
args[0].delete(:crop_length) if args[0][:crop_length]
|
271
271
|
end
|
272
272
|
|
273
273
|
SafeIndex.log_or_throw(m, @raise_on_failure) do
|
@@ -581,15 +581,15 @@ module MeiliSearch
|
|
581
581
|
def ms_raw_search(q, params = {})
|
582
582
|
index_uid = params.delete(:index) || params.delete('index')
|
583
583
|
|
584
|
-
unless meilisearch_settings.get_setting(:
|
585
|
-
params[:
|
584
|
+
unless meilisearch_settings.get_setting(:attributes_to_highlight).nil?
|
585
|
+
params[:attributes_to_highlight] = meilisearch_settings.get_setting(:attributes_to_highlight)
|
586
586
|
end
|
587
587
|
|
588
|
-
unless meilisearch_settings.get_setting(:
|
589
|
-
params[:
|
588
|
+
unless meilisearch_settings.get_setting(:attributes_to_crop).nil?
|
589
|
+
params[:attributes_to_crop] = meilisearch_settings.get_setting(:attributes_to_crop)
|
590
590
|
|
591
|
-
unless meilisearch_settings.get_setting(:
|
592
|
-
params[:
|
591
|
+
unless meilisearch_settings.get_setting(:crop_length).nil?
|
592
|
+
params[:crop_length] = meilisearch_settings.get_setting(:crop_length)
|
593
593
|
end
|
594
594
|
end
|
595
595
|
|
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.10.
|
4
|
+
version: 0.10.1
|
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-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: meilisearch
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/meilisearch/rails/pagination/will_paginate.rb
|
48
48
|
- lib/meilisearch/rails/railtie.rb
|
49
49
|
- lib/meilisearch/rails/tasks/meilisearch.rake
|
50
|
+
- lib/meilisearch/rails/templates/initializer.rb
|
50
51
|
- lib/meilisearch/rails/utilities.rb
|
51
52
|
- lib/meilisearch/rails/version.rb
|
52
53
|
- meilisearch-rails.gemspec
|