algoliasearch-rails 1.20.6 → 1.21.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/.travis.yml +43 -51
- data/ChangeLog +30 -0
- data/Gemfile +4 -2
- data/Gemfile.lock +105 -88
- data/README.md +3 -9
- data/lib/algoliasearch-rails.rb +59 -31
- data/lib/algoliasearch/version.rb +1 -1
- data/spec/spec_helper.rb +19 -4
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1eb55772f506326a5847dbc0ebee0674f23c8a382b3eea7c3fddc01b9039150d
|
4
|
+
data.tar.gz: f41c8aa08a1d28ddf8f88643bb5e6231e4f447e49ff21714d0b803e6c0567394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c763ac336f5cb507a73dbaf5b1d2be086bef6260054c3887bf2d7fa568fb513e8611151a2adfedf1f9b52d738e3cf2cb626eb9e44439a9dea2715fea501ced0
|
7
|
+
data.tar.gz: 7df4726bca1c2d10aa9037d83da3a7d15684d39d429db8f5bda5b25b722edbe4c3d41538d58f96e1874a5acd5e33a3ccc6ba0437ca3b9373cdde35da63b8dd23
|
data/.travis.yml
CHANGED
@@ -1,61 +1,53 @@
|
|
1
1
|
language: ruby
|
2
|
+
|
2
3
|
branches:
|
3
4
|
only:
|
4
|
-
|
5
|
+
- master
|
6
|
+
|
5
7
|
matrix:
|
6
8
|
include:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
|
37
|
-
# - rvm: jruby-9.1.2.0
|
38
|
-
# env: RAILS_VERSION=3.2.0
|
39
|
-
# - rvm: jruby-9.1.2.0
|
40
|
-
# env: RAILS_VERSION=4.2
|
41
|
-
# - rvm: jruby-9.1.2.0
|
42
|
-
# env: RAILS_VERSION=5.0
|
43
|
-
# - rvm: rbx-2
|
44
|
-
# env: RAILS_VERSION=3.2.0
|
45
|
-
# - rvm: rbx-2
|
46
|
-
# env: RAILS_VERSION=4.2
|
47
|
-
# - rvm: rbx-3.20
|
48
|
-
# env: RAILS_VERSION=3.2.0
|
49
|
-
# - rvm: rbx-3.20
|
50
|
-
# env: RAILS_VERSION=4.2
|
51
|
-
# - rvm: rbx-3.20
|
52
|
-
# env: RAILS_VERSION=5.0
|
53
|
-
allow_failures:
|
54
|
-
- rvm: rbx-2
|
9
|
+
- rvm: 1.8.7
|
10
|
+
env: RAILS_VERSION=3.2.0 SEQUEL_VERSION=4.0
|
11
|
+
- rvm: 1.9.3
|
12
|
+
env: RAILS_VERSION=3.2.0
|
13
|
+
- rvm: 1.9.3
|
14
|
+
env: RAILS_VERSION=4.2
|
15
|
+
- rvm: 2.2.9
|
16
|
+
env: RAILS_VERSION=3.2.0
|
17
|
+
- rvm: 2.2.9
|
18
|
+
env: RAILS_VERSION=4.2
|
19
|
+
- rvm: 2.2.9
|
20
|
+
env: RAILS_VERSION=5.1
|
21
|
+
- rvm: 2.3.6
|
22
|
+
env: RAILS_VERSION=3.2.0
|
23
|
+
- rvm: 2.3.6
|
24
|
+
env: RAILS_VERSION=4.2
|
25
|
+
- rvm: 2.3.6
|
26
|
+
env: RAILS_VERSION=5.1
|
27
|
+
- rvm: 2.4.3
|
28
|
+
env: RAILS_VERSION=4.2
|
29
|
+
- rvm: 2.4.3
|
30
|
+
env: RAILS_VERSION=5.1 SEQUEL_VERSION=4.0
|
31
|
+
- rvm: 2.4.3
|
32
|
+
env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
|
33
|
+
- rvm: 2.5.3
|
34
|
+
env: RAILS_VERSION=5.1 SEQUEL_VERSION=5.0
|
35
|
+
- rvm: 2.6.0
|
36
|
+
env: RAILS_VERSION=5.2 SEQUEL_VERSION=5.0
|
37
|
+
|
55
38
|
before_install:
|
56
39
|
- wget http://api-key-dealer.herokuapp.com/clients/algolia-keys && chmod +x algolia-keys
|
57
|
-
-
|
40
|
+
- which bundle || true
|
41
|
+
- find /home/travis/.rvm -wholename "*/bundler-*.gemspec" -print -delete || true
|
42
|
+
- bundle --version || true
|
43
|
+
- gem uninstall bundler || true
|
44
|
+
- bundle --version || true
|
45
|
+
- gem install bundler -v 1.17.3
|
58
46
|
- bundle --version
|
47
|
+
|
59
48
|
install: rm -f Gemfile.lock && bundle install --without development
|
49
|
+
|
60
50
|
cache: bundler
|
61
|
-
|
51
|
+
|
52
|
+
script:
|
53
|
+
- eval $(./algolia-keys export) && bundle exec rake
|
data/ChangeLog
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
## [1.21.0](https://github.com/algolia/algoliasearch-rails/releases/tag/1.21.0) (2019-02-12)
|
4
|
+
|
5
|
+
**Added**
|
6
|
+
|
7
|
+
* Add `AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE` constant - PR [#319](https://github.com/algolia/algoliasearch-rails/pull/319)
|
8
|
+
|
9
|
+
* Support ActiveModel Serializer 🎉 - PR [#266](https://github.com/algolia/algoliasearch-rails/pull/266)
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class SerializedObject < ActiveRecord::Base
|
13
|
+
include AlgoliaSearch
|
14
|
+
|
15
|
+
algoliasearch do
|
16
|
+
|
17
|
+
use_serializer SerializedObjectSerializer
|
18
|
+
|
19
|
+
tags do
|
20
|
+
['tag1', 'tag2']
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
```
|
26
|
+
|
27
|
+
**Fixed**
|
28
|
+
|
29
|
+
* Add support for all new recent engine settings - PR [#327](https://github.com/algolia/algoliasearch-rails/pull/327)
|
30
|
+
|
31
|
+
Algolia regularly introduce new settings, all of them are supported by this gem.
|
32
|
+
|
3
33
|
2018-12-07 1.20.6
|
4
34
|
|
5
35
|
* Better support for Rails 5.1 and deprecated `attribute_changed?`
|
data/Gemfile
CHANGED
@@ -10,6 +10,7 @@ end
|
|
10
10
|
group :test do
|
11
11
|
rails_version = ENV["RAILS_VERSION"] ? "~> #{ENV["RAILS_VERSION"]}" : '>= 3.2.0'
|
12
12
|
gem 'rails', rails_version
|
13
|
+
gem 'active_model_serializers'
|
13
14
|
if defined?(RUBY_VERSION) && RUBY_VERSION == "1.8.7"
|
14
15
|
gem 'i18n', '< 0.7'
|
15
16
|
gem 'highline', '< 1.7'
|
@@ -20,7 +21,7 @@ group :test do
|
|
20
21
|
gem 'faraday', '< 0.10'
|
21
22
|
elsif defined?(RUBY_VERSION) && RUBY_VERSION == "1.9.3"
|
22
23
|
gem 'rack', '< 2'
|
23
|
-
gem '
|
24
|
+
gem 'rack-cache', '<= 1.7.1'
|
24
25
|
if Gem::Version.new(ENV['RAILS_VERSION'] || '3.2.0') >= Gem::Version.new('4.0')
|
25
26
|
gem 'mime-types', '~> 2.6'
|
26
27
|
else
|
@@ -34,7 +35,7 @@ group :test do
|
|
34
35
|
gem 'net-http-persistent', '< 3.0'
|
35
36
|
end
|
36
37
|
gem 'rspec', '>= 2.5.0', '< 3.0'
|
37
|
-
gem 'sqlite3', :platform => [:rbx, :ruby]
|
38
|
+
gem 'sqlite3', '< 1.4.0', :platform => [:rbx, :ruby]
|
38
39
|
gem 'jdbc-sqlite3', :platform => :jruby
|
39
40
|
gem 'activerecord-jdbc-adapter', :platform => :jruby
|
40
41
|
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
@@ -61,3 +62,4 @@ group :test, :development do
|
|
61
62
|
gem 'kaminari'
|
62
63
|
end
|
63
64
|
end
|
65
|
+
|
data/Gemfile.lock
CHANGED
@@ -1,56 +1,68 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
actioncable (5.
|
5
|
-
actionpack (= 5.
|
6
|
-
nio4r (
|
7
|
-
websocket-driver (
|
8
|
-
actionmailer (5.
|
9
|
-
actionpack (= 5.
|
10
|
-
actionview (= 5.
|
11
|
-
activejob (= 5.
|
4
|
+
actioncable (5.2.2)
|
5
|
+
actionpack (= 5.2.2)
|
6
|
+
nio4r (~> 2.0)
|
7
|
+
websocket-driver (>= 0.6.1)
|
8
|
+
actionmailer (5.2.2)
|
9
|
+
actionpack (= 5.2.2)
|
10
|
+
actionview (= 5.2.2)
|
11
|
+
activejob (= 5.2.2)
|
12
12
|
mail (~> 2.5, >= 2.5.4)
|
13
13
|
rails-dom-testing (~> 2.0)
|
14
|
-
actionpack (5.
|
15
|
-
actionview (= 5.
|
16
|
-
activesupport (= 5.
|
14
|
+
actionpack (5.2.2)
|
15
|
+
actionview (= 5.2.2)
|
16
|
+
activesupport (= 5.2.2)
|
17
17
|
rack (~> 2.0)
|
18
|
-
rack-test (
|
18
|
+
rack-test (>= 0.6.3)
|
19
19
|
rails-dom-testing (~> 2.0)
|
20
20
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
21
|
-
actionview (5.
|
22
|
-
activesupport (= 5.
|
21
|
+
actionview (5.2.2)
|
22
|
+
activesupport (= 5.2.2)
|
23
23
|
builder (~> 3.1)
|
24
|
-
|
24
|
+
erubi (~> 1.4)
|
25
25
|
rails-dom-testing (~> 2.0)
|
26
26
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
27
|
-
|
28
|
-
|
27
|
+
active_model_serializers (0.10.8)
|
28
|
+
actionpack (>= 4.1, < 6)
|
29
|
+
activemodel (>= 4.1, < 6)
|
30
|
+
case_transform (>= 0.2)
|
31
|
+
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
32
|
+
activejob (5.2.2)
|
33
|
+
activesupport (= 5.2.2)
|
29
34
|
globalid (>= 0.3.6)
|
30
|
-
activemodel (5.
|
31
|
-
activesupport (= 5.
|
32
|
-
activerecord (5.
|
33
|
-
activemodel (= 5.
|
34
|
-
activesupport (= 5.
|
35
|
-
arel (
|
36
|
-
|
35
|
+
activemodel (5.2.2)
|
36
|
+
activesupport (= 5.2.2)
|
37
|
+
activerecord (5.2.2)
|
38
|
+
activemodel (= 5.2.2)
|
39
|
+
activesupport (= 5.2.2)
|
40
|
+
arel (>= 9.0)
|
41
|
+
activestorage (5.2.2)
|
42
|
+
actionpack (= 5.2.2)
|
43
|
+
activerecord (= 5.2.2)
|
44
|
+
marcel (~> 0.3.1)
|
45
|
+
activesupport (5.2.2)
|
37
46
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
38
|
-
i18n (
|
47
|
+
i18n (>= 0.7, < 2)
|
39
48
|
minitest (~> 5.1)
|
40
49
|
tzinfo (~> 1.1)
|
41
50
|
addressable (2.4.0)
|
42
|
-
algoliasearch (1.
|
51
|
+
algoliasearch (1.25.2)
|
43
52
|
httpclient (~> 2.8, >= 2.8.3)
|
44
53
|
json (>= 1.5.1)
|
45
|
-
arel (
|
46
|
-
backports (3.11.
|
54
|
+
arel (9.0.0)
|
55
|
+
backports (3.11.4)
|
47
56
|
builder (3.2.3)
|
48
|
-
|
57
|
+
case_transform (0.2)
|
58
|
+
activesupport
|
59
|
+
concurrent-ruby (1.1.4)
|
60
|
+
crass (1.0.4)
|
49
61
|
diff-lcs (1.3)
|
50
|
-
|
62
|
+
erubi (1.8.0)
|
51
63
|
ethon (0.11.0)
|
52
64
|
ffi (>= 1.3.0)
|
53
|
-
faraday (0.15.
|
65
|
+
faraday (0.15.4)
|
54
66
|
multipart-post (>= 1.2, < 3)
|
55
67
|
faraday_middleware (0.12.2)
|
56
68
|
faraday (>= 0.7.4, < 1.0)
|
@@ -62,75 +74,79 @@ GEM
|
|
62
74
|
multi_json (~> 1.0)
|
63
75
|
net-http-persistent (~> 2.9)
|
64
76
|
net-http-pipeline
|
65
|
-
globalid (0.
|
66
|
-
activesupport (>= 4.
|
77
|
+
globalid (0.4.1)
|
78
|
+
activesupport (>= 4.2.0)
|
67
79
|
highline (1.7.10)
|
68
80
|
httpclient (2.8.3)
|
69
|
-
i18n (
|
81
|
+
i18n (1.4.0)
|
70
82
|
concurrent-ruby (~> 1.0)
|
71
83
|
json (1.8.6)
|
72
|
-
|
84
|
+
jsonapi-renderer (0.2.0)
|
85
|
+
kaminari (1.1.1)
|
73
86
|
activesupport (>= 4.1.0)
|
74
|
-
kaminari-actionview (= 1.
|
75
|
-
kaminari-activerecord (= 1.
|
76
|
-
kaminari-core (= 1.
|
77
|
-
kaminari-actionview (1.
|
87
|
+
kaminari-actionview (= 1.1.1)
|
88
|
+
kaminari-activerecord (= 1.1.1)
|
89
|
+
kaminari-core (= 1.1.1)
|
90
|
+
kaminari-actionview (1.1.1)
|
78
91
|
actionview
|
79
|
-
kaminari-core (= 1.
|
80
|
-
kaminari-activerecord (1.
|
92
|
+
kaminari-core (= 1.1.1)
|
93
|
+
kaminari-activerecord (1.1.1)
|
81
94
|
activerecord
|
82
|
-
kaminari-core (= 1.
|
83
|
-
kaminari-core (1.
|
95
|
+
kaminari-core (= 1.1.1)
|
96
|
+
kaminari-core (1.1.1)
|
84
97
|
launchy (2.4.3)
|
85
98
|
addressable (~> 2.3)
|
86
|
-
loofah (2.
|
99
|
+
loofah (2.2.3)
|
100
|
+
crass (~> 1.0.2)
|
87
101
|
nokogiri (>= 1.5.9)
|
88
|
-
mail (2.
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
102
|
+
mail (2.7.1)
|
103
|
+
mini_mime (>= 0.1.1)
|
104
|
+
marcel (0.3.3)
|
105
|
+
mimemagic (~> 0.3.2)
|
106
|
+
method_source (0.9.2)
|
107
|
+
mimemagic (0.3.3)
|
108
|
+
mini_mime (1.0.1)
|
109
|
+
mini_portile2 (2.4.0)
|
95
110
|
minitest (5.11.3)
|
96
111
|
multi_json (1.13.1)
|
97
112
|
multipart-post (2.0.0)
|
98
113
|
net-http-persistent (2.9.4)
|
99
114
|
net-http-pipeline (1.0.1)
|
100
|
-
nio4r (2.
|
101
|
-
nokogiri (1.
|
102
|
-
mini_portile2 (~> 2.
|
115
|
+
nio4r (2.3.1)
|
116
|
+
nokogiri (1.9.1)
|
117
|
+
mini_portile2 (~> 2.4.0)
|
103
118
|
pusher-client (0.6.2)
|
104
119
|
json
|
105
120
|
websocket (~> 1.0)
|
106
|
-
rack (2.0.
|
107
|
-
rack-test (
|
108
|
-
rack (>= 1.0)
|
109
|
-
rails (5.
|
110
|
-
actioncable (= 5.
|
111
|
-
actionmailer (= 5.
|
112
|
-
actionpack (= 5.
|
113
|
-
actionview (= 5.
|
114
|
-
activejob (= 5.
|
115
|
-
activemodel (= 5.
|
116
|
-
activerecord (= 5.
|
117
|
-
|
118
|
-
|
119
|
-
|
121
|
+
rack (2.0.6)
|
122
|
+
rack-test (1.1.0)
|
123
|
+
rack (>= 1.0, < 3)
|
124
|
+
rails (5.2.2)
|
125
|
+
actioncable (= 5.2.2)
|
126
|
+
actionmailer (= 5.2.2)
|
127
|
+
actionpack (= 5.2.2)
|
128
|
+
actionview (= 5.2.2)
|
129
|
+
activejob (= 5.2.2)
|
130
|
+
activemodel (= 5.2.2)
|
131
|
+
activerecord (= 5.2.2)
|
132
|
+
activestorage (= 5.2.2)
|
133
|
+
activesupport (= 5.2.2)
|
134
|
+
bundler (>= 1.3.0)
|
135
|
+
railties (= 5.2.2)
|
120
136
|
sprockets-rails (>= 2.0.0)
|
121
|
-
rails-dom-testing (2.0.
|
122
|
-
activesupport (>= 4.2.0
|
123
|
-
nokogiri (
|
124
|
-
rails-html-sanitizer (1.0.
|
125
|
-
loofah (~> 2.
|
126
|
-
railties (5.
|
127
|
-
actionpack (= 5.
|
128
|
-
activesupport (= 5.
|
137
|
+
rails-dom-testing (2.0.3)
|
138
|
+
activesupport (>= 4.2.0)
|
139
|
+
nokogiri (>= 1.6)
|
140
|
+
rails-html-sanitizer (1.0.4)
|
141
|
+
loofah (~> 2.2, >= 2.2.2)
|
142
|
+
railties (5.2.2)
|
143
|
+
actionpack (= 5.2.2)
|
144
|
+
activesupport (= 5.2.2)
|
129
145
|
method_source
|
130
146
|
rake (>= 0.8.7)
|
131
|
-
thor (>= 0.
|
147
|
+
thor (>= 0.19.0, < 2.0)
|
132
148
|
rake (10.1.1)
|
133
|
-
rdoc (6.
|
149
|
+
rdoc (6.1.1)
|
134
150
|
redgreen (1.2.2)
|
135
151
|
rspec (2.99.0)
|
136
152
|
rspec-core (~> 2.99.0)
|
@@ -140,18 +156,18 @@ GEM
|
|
140
156
|
rspec-expectations (2.99.2)
|
141
157
|
diff-lcs (>= 1.1.3, < 2.0)
|
142
158
|
rspec-mocks (2.99.4)
|
143
|
-
sequel (
|
144
|
-
sprockets (3.7.
|
159
|
+
sequel (5.16.0)
|
160
|
+
sprockets (3.7.2)
|
145
161
|
concurrent-ruby (~> 1.0)
|
146
162
|
rack (> 1, < 3)
|
147
|
-
sprockets-rails (3.2.
|
163
|
+
sprockets-rails (3.2.1)
|
148
164
|
actionpack (>= 4.0)
|
149
165
|
activesupport (>= 4.0)
|
150
166
|
sprockets (>= 3.0.0)
|
151
167
|
sqlite3 (1.3.13)
|
152
|
-
thor (0.20.
|
168
|
+
thor (0.20.3)
|
153
169
|
thread_safe (0.3.6)
|
154
|
-
travis (1.8.
|
170
|
+
travis (1.8.9)
|
155
171
|
backports
|
156
172
|
faraday (~> 0.9)
|
157
173
|
faraday_middleware (~> 0.9, >= 0.9.1)
|
@@ -164,16 +180,17 @@ GEM
|
|
164
180
|
ethon (>= 0.8.0)
|
165
181
|
tzinfo (1.2.5)
|
166
182
|
thread_safe (~> 0.1)
|
167
|
-
websocket (1.2.
|
168
|
-
websocket-driver (0.
|
183
|
+
websocket (1.2.8)
|
184
|
+
websocket-driver (0.7.0)
|
169
185
|
websocket-extensions (>= 0.1.0)
|
170
|
-
websocket-extensions (0.1.
|
171
|
-
will_paginate (3.1.
|
186
|
+
websocket-extensions (0.1.3)
|
187
|
+
will_paginate (3.1.6)
|
172
188
|
|
173
189
|
PLATFORMS
|
174
190
|
ruby
|
175
191
|
|
176
192
|
DEPENDENCIES
|
193
|
+
active_model_serializers
|
177
194
|
activerecord-jdbc-adapter
|
178
195
|
activerecord-jdbcsqlite3-adapter
|
179
196
|
algoliasearch (>= 1.17.0, < 2.0.0)
|
@@ -191,4 +208,4 @@ DEPENDENCIES
|
|
191
208
|
will_paginate (>= 2.3.15)
|
192
209
|
|
193
210
|
BUNDLED WITH
|
194
|
-
1.
|
211
|
+
1.17.3
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
|
2
2
|
# Algolia Search API Client for Rails
|
3
3
|
|
4
|
-
[Algolia Search](https://www.algolia.com) is a hosted
|
5
|
-
and faceted search engine capable of delivering realtime results from the first keystroke.
|
4
|
+
[Algolia Search](https://www.algolia.com) is a hosted search engine capable of delivering real-time results from the first keystroke.
|
6
5
|
|
7
6
|
[](https://travis-ci.org/algolia/algoliasearch-rails) [](http://badge.fury.io/rb/algoliasearch-rails) [](https://codeclimate.com/github/algolia/algoliasearch-rails)   
|
8
7
|
|
@@ -16,7 +15,7 @@ You might be interested in the sample Ruby on Rails application providing a `aut
|
|
16
15
|
|
17
16
|
## API Documentation
|
18
17
|
|
19
|
-
You can find the full reference on [Algolia's website](https://www.algolia.com/doc/
|
18
|
+
You can find the full reference on [Algolia's website](https://www.algolia.com/doc/framework-integration/rails/).
|
20
19
|
|
21
20
|
|
22
21
|
|
@@ -68,7 +67,6 @@ You can find the full reference on [Algolia's website](https://www.algolia.com/d
|
|
68
67
|
|
69
68
|
|
70
69
|
|
71
|
-
|
72
70
|
# Setup
|
73
71
|
|
74
72
|
|
@@ -131,7 +129,6 @@ Contact.algolia_search("jon doe") # <=> Contact.search("jon doe")
|
|
131
129
|
|
132
130
|
|
133
131
|
|
134
|
-
|
135
132
|
# Usage
|
136
133
|
|
137
134
|
|
@@ -406,7 +403,7 @@ Product.search_for_facet_values('category', 'phone', {
|
|
406
403
|
## Group by
|
407
404
|
|
408
405
|
More info on distinct for grouping can be found
|
409
|
-
[here](https://www.algolia.com/doc/guides/
|
406
|
+
[here](https://www.algolia.com/doc/guides/managing-results/refine-results/grouping/).
|
410
407
|
|
411
408
|
```ruby
|
412
409
|
class Contact < ActiveRecord::Base
|
@@ -440,7 +437,6 @@ At query time, specify <code>{ aroundLatLng: "37.33, -121.89", aroundRadius: 500
|
|
440
437
|
|
441
438
|
|
442
439
|
|
443
|
-
|
444
440
|
# Options
|
445
441
|
|
446
442
|
|
@@ -935,7 +931,6 @@ end
|
|
935
931
|
|
936
932
|
|
937
933
|
|
938
|
-
|
939
934
|
# Indices
|
940
935
|
|
941
936
|
|
@@ -1118,7 +1113,6 @@ Book.search 'foo bar', index: 'Book_by_editor'
|
|
1118
1113
|
|
1119
1114
|
|
1120
1115
|
|
1121
|
-
|
1122
1116
|
# Testing
|
1123
1117
|
|
1124
1118
|
|
data/lib/algoliasearch-rails.rb
CHANGED
@@ -47,20 +47,43 @@ module AlgoliaSearch
|
|
47
47
|
end
|
48
48
|
|
49
49
|
class IndexSettings
|
50
|
+
DEFAULT_BATCH_SIZE = 1000
|
50
51
|
|
51
52
|
# AlgoliaSearch settings
|
52
|
-
OPTIONS = [
|
53
|
-
|
54
|
-
:
|
55
|
-
:
|
56
|
-
|
57
|
-
:
|
58
|
-
|
59
|
-
:
|
60
|
-
|
61
|
-
:
|
62
|
-
:
|
63
|
-
|
53
|
+
OPTIONS = [
|
54
|
+
# Attributes
|
55
|
+
:searchableAttributes, :attributesForFaceting, :unretrievableAttributes, :attributesToRetrieve,
|
56
|
+
:attributesToIndex, #Legacy name of searchableAttributes
|
57
|
+
# Ranking
|
58
|
+
:ranking, :customRanking, # Replicas are handled via `add_replica`
|
59
|
+
# Faceting
|
60
|
+
:maxValuesPerFacet, :sortFacetValuesBy,
|
61
|
+
# Highlighting / Snippeting
|
62
|
+
:attributesToHighlight, :attributesToSnippet, :highlightPreTag, :highlightPostTag,
|
63
|
+
:snippetEllipsisText, :restrictHighlightAndSnippetArrays,
|
64
|
+
# Pagination
|
65
|
+
:hitsPerPage, :paginationLimitedTo,
|
66
|
+
# Typo
|
67
|
+
:minWordSizefor1Typo, :minWordSizefor2Typos, :typoTolerance, :allowTyposOnNumericTokens,
|
68
|
+
:disableTypoToleranceOnAttributes, :disableTypoToleranceOnWords, :separatorsToIndex,
|
69
|
+
# Language
|
70
|
+
:ignorePlurals, :removeStopWords, :camelCaseAttributes, :decompoundedAttributes,
|
71
|
+
:keepDiacriticsOnCharacters, :queryLanguages,
|
72
|
+
# Query Rules
|
73
|
+
:enableRules,
|
74
|
+
# Query Strategy
|
75
|
+
:queryType, :removeWordsIfNoResults, :advancedSyntax, :optionalWords,
|
76
|
+
:disablePrefixOnAttributes, :disableExactOnAttributes, :exactOnSingleWordQuery, :alternativesAsExact,
|
77
|
+
# Performance
|
78
|
+
:numericAttributesForFiltering, :allowCompressionOfIntegerArray,
|
79
|
+
:numericAttributesToIndex, # Legacy name of numericAttributesForFiltering
|
80
|
+
# Advanced
|
81
|
+
:attributeForDistinct, :distinct, :replaceSynonymsInHighlight, :minProximity, :responseFields,
|
82
|
+
:maxFacetHits,
|
83
|
+
|
84
|
+
# Rails-specific
|
85
|
+
:synonyms, :placeholders, :altCorrections,
|
86
|
+
]
|
64
87
|
OPTIONS.each do |k|
|
65
88
|
define_method k do |v|
|
66
89
|
instance_variable_set("@#{k}", v)
|
@@ -72,6 +95,11 @@ module AlgoliaSearch
|
|
72
95
|
instance_exec(&block) if block
|
73
96
|
end
|
74
97
|
|
98
|
+
def use_serializer(serializer)
|
99
|
+
@serializer = serializer
|
100
|
+
# instance_variable_set("@serializer", serializer)
|
101
|
+
end
|
102
|
+
|
75
103
|
def attribute(*names, &block)
|
76
104
|
raise ArgumentError.new('Cannot pass multiple attribute names if block given') if block_given? and names.length > 1
|
77
105
|
raise ArgumentError.new('Cannot specify additional attributes on a replica index') if @options[:slave] || @options[:replica]
|
@@ -118,15 +146,7 @@ module AlgoliaSearch
|
|
118
146
|
end
|
119
147
|
|
120
148
|
def get_attribute_names(object)
|
121
|
-
|
122
|
-
get_default_attributes(object).keys
|
123
|
-
else
|
124
|
-
@attributes.keys
|
125
|
-
end
|
126
|
-
|
127
|
-
res += @additional_attributes.keys if @additional_attributes
|
128
|
-
|
129
|
-
res
|
149
|
+
get_attributes(object).keys
|
130
150
|
end
|
131
151
|
|
132
152
|
def attributes_to_hash(attributes, object)
|
@@ -138,19 +158,27 @@ module AlgoliaSearch
|
|
138
158
|
end
|
139
159
|
|
140
160
|
def get_attributes(object)
|
141
|
-
|
142
|
-
|
161
|
+
# If a serializer is set, we ignore attributes
|
162
|
+
# everything should be done via the serializer
|
163
|
+
if not @serializer.nil?
|
164
|
+
attributes = @serializer.new(object).attributes
|
143
165
|
else
|
144
|
-
if
|
145
|
-
|
146
|
-
|
147
|
-
end
|
166
|
+
if @attributes.nil? || @attributes.length == 0
|
167
|
+
# no `attribute ...` have been configured, use the default attributes of the model
|
168
|
+
attributes = get_default_attributes(object)
|
148
169
|
else
|
149
|
-
|
170
|
+
# at least 1 `attribute ...` has been configured, therefore use ONLY the one configured
|
171
|
+
if is_active_record?(object)
|
172
|
+
object.class.unscoped do
|
173
|
+
attributes = attributes_to_hash(@attributes, object)
|
174
|
+
end
|
175
|
+
else
|
176
|
+
attributes = attributes_to_hash(@attributes, object)
|
177
|
+
end
|
150
178
|
end
|
151
179
|
end
|
152
180
|
|
153
|
-
attributes.merge!(attributes_to_hash(@additional_attributes, object))
|
181
|
+
attributes.merge!(attributes_to_hash(@additional_attributes, object)) if @additional_attributes
|
154
182
|
|
155
183
|
if @options[:sanitize]
|
156
184
|
sanitizer = begin
|
@@ -478,7 +506,7 @@ module AlgoliaSearch
|
|
478
506
|
Thread.current["algolia_without_auto_index_scope_for_#{self.model_name}"]
|
479
507
|
end
|
480
508
|
|
481
|
-
def algolia_reindex!(batch_size =
|
509
|
+
def algolia_reindex!(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE, synchronous = false)
|
482
510
|
return if algolia_without_auto_index_scope
|
483
511
|
algolia_configurations.each do |options, settings|
|
484
512
|
next if algolia_indexing_disabled?(options)
|
@@ -509,7 +537,7 @@ module AlgoliaSearch
|
|
509
537
|
end
|
510
538
|
|
511
539
|
# reindex whole database using a extra temporary index + move operation
|
512
|
-
def algolia_reindex(batch_size =
|
540
|
+
def algolia_reindex(batch_size = AlgoliaSearch::IndexSettings::DEFAULT_BATCH_SIZE, synchronous = false)
|
513
541
|
return if algolia_without_auto_index_scope
|
514
542
|
algolia_configurations.each do |options, settings|
|
515
543
|
next if algolia_indexing_disabled?(options)
|
data/spec/spec_helper.rb
CHANGED
@@ -26,11 +26,26 @@ RSpec.configure do |c|
|
|
26
26
|
example.run
|
27
27
|
}
|
28
28
|
end
|
29
|
+
|
30
|
+
# Remove all indexes setup in this run in local or CI
|
31
|
+
c.after(:suite) do
|
32
|
+
safe_index_list.each do |index|
|
33
|
+
Algolia.client.delete_index!(index['name'])
|
34
|
+
end
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
|
-
#
|
38
|
+
# A unique prefix for your test run in local or CI
|
39
|
+
SAFE_INDEX_PREFIX = "rails_#{SecureRandom.hex(8)}".freeze
|
40
|
+
|
41
|
+
# avoid concurrent access to the same index in local or CI
|
32
42
|
def safe_index_name(name)
|
33
|
-
|
34
|
-
|
35
|
-
|
43
|
+
"#{SAFE_INDEX_PREFIX}_#{name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
# get a list of safe indexes in local or CI
|
47
|
+
def safe_index_list
|
48
|
+
list = Algolia.client.list_indexes()['items']
|
49
|
+
list = list.select { |index| index["name"].include?(SAFE_INDEX_PREFIX) }
|
50
|
+
list.sort_by { |index| index["primary"] || "" }
|
36
51
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algoliasearch-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.21.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Algolia
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -188,8 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
188
188
|
- !ruby/object:Gem::Version
|
189
189
|
version: '0'
|
190
190
|
requirements: []
|
191
|
-
|
192
|
-
rubygems_version: 2.7.7
|
191
|
+
rubygems_version: 3.0.2
|
193
192
|
signing_key:
|
194
193
|
specification_version: 4
|
195
194
|
summary: AlgoliaSearch integration to your favorite ORM
|