algoliasearch-rails 1.10.7 → 1.10.8
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 +2 -2
- data/ChangeLog +4 -0
- data/README.md +35 -2
- data/VERSION +1 -1
- data/algoliasearch-rails.gemspec +2 -2
- data/lib/algoliasearch-rails.rb +6 -1
- metadata +5 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44e136c402b306cd7c5be8d13a9802d80a67c52a
|
|
4
|
+
data.tar.gz: 8b169df8210d519c047ed866c501dfc2af41d695
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 89c7c31981f23b19eae9da07fb580e9951a2e1557f1a953fbed1e6be4b9ebcb43d73b8aaf141059b8dec9f287fba9a8d19f5bc8d4c1a3dcfd71bc60cfd8e0b18
|
|
7
|
+
data.tar.gz: 8131804d5fc2c711e11cec579fb66fd1c302d36b3adc55ef5965deec138d677d7b1a92efec99fd5fdf95e8555c4c8746b8523e57b5cbbebfcb6e154efdb06141
|
data/.travis.yml
CHANGED
|
@@ -11,5 +11,5 @@ rvm:
|
|
|
11
11
|
- rbx-2
|
|
12
12
|
env:
|
|
13
13
|
global:
|
|
14
|
-
- secure:
|
|
15
|
-
- secure:
|
|
14
|
+
- secure: kD+PX8ZNg+AAzyr6WYs1vp9teAkzMfEoYkIMI0hrRN0ml9ccJVsJR1pIGpaIwyCa5PmFtCZ1Xi2vFb4XzTTeaZoHHS/ll9LwuQH6mwvdgj3n6TmNRdq3b/oGRHBX4Z0HMobqaftuzY/V8iTpVk92jwIY8NPj00k055b2jrKqhdw=
|
|
15
|
+
- secure: Eai99h4K7s9/Sh3CHClWs3IQNaEUdVagpmA/A8m0rysGBAYJdMKbUOp9DZPAmCnT+06l0aFv87+CRYtgyX05pE5f21nqBOU46eKS38cLif3aPTwFmwokf28WLDgmZKa/zJp767SiQ/dp0hz+LJrkJvkDRnA1un36f7wiyY9xnYs=
|
data/ChangeLog
CHANGED
data/README.md
CHANGED
|
@@ -106,6 +106,17 @@ class Product < ActiveRecord::Base
|
|
|
106
106
|
end
|
|
107
107
|
```
|
|
108
108
|
|
|
109
|
+
#### Frontend Search (realtime experience)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
We recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-js) to perform queries. The JS API client is part of the gem, just require ```algolia/algoliasearch.min``` somewhere in your JavaScript manifest, for example in ```application.js``` if you are using Rails 3.1+:
|
|
113
|
+
|
|
114
|
+
```javascript
|
|
115
|
+
//= require algolia/algoliasearch.min
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
#### Backend Search
|
|
119
|
+
|
|
109
120
|
A search returns ORM-compliant objects reloading them from your database.
|
|
110
121
|
|
|
111
122
|
```ruby
|
|
@@ -118,9 +129,9 @@ If you want to retrieve the raw JSON answer from the API, without re-loading the
|
|
|
118
129
|
p Contact.raw_search("jon doe")
|
|
119
130
|
```
|
|
120
131
|
|
|
121
|
-
|
|
132
|
+
#### Notes
|
|
122
133
|
|
|
123
|
-
|
|
134
|
+
All methods injected by the ```AlgoliaSearch``` include are prefixed by ```algolia_``` and aliased to the associated short names if they aren't already defined.
|
|
124
135
|
|
|
125
136
|
```ruby
|
|
126
137
|
Contact.algolia_reindex! # <=> Contact.reindex!
|
|
@@ -131,6 +142,8 @@ Contact.algolia_search("jon doe") # <=> Contact.search("jon doe")
|
|
|
131
142
|
Options
|
|
132
143
|
----------
|
|
133
144
|
|
|
145
|
+
#### Auto-indexing & asynchronism
|
|
146
|
+
|
|
134
147
|
Each time a record is saved; it will be - asynchronously - indexed. On the other hand, each time a record is destroyed, it will be - asynchronously - removed from the index.
|
|
135
148
|
|
|
136
149
|
You can disable auto-indexing and auto-removing setting the following options:
|
|
@@ -167,6 +180,8 @@ class Contact < ActiveRecord::Base
|
|
|
167
180
|
end
|
|
168
181
|
```
|
|
169
182
|
|
|
183
|
+
#### Custom index name
|
|
184
|
+
|
|
170
185
|
You can force the index name using the following option:
|
|
171
186
|
|
|
172
187
|
```ruby
|
|
@@ -179,6 +194,8 @@ class Contact < ActiveRecord::Base
|
|
|
179
194
|
end
|
|
180
195
|
```
|
|
181
196
|
|
|
197
|
+
#### Per-environment indexes
|
|
198
|
+
|
|
182
199
|
You can suffix the index name with the current Rails environment using the following option:
|
|
183
200
|
|
|
184
201
|
```ruby
|
|
@@ -191,6 +208,8 @@ class Contact < ActiveRecord::Base
|
|
|
191
208
|
end
|
|
192
209
|
```
|
|
193
210
|
|
|
211
|
+
#### Custom attribute definition
|
|
212
|
+
|
|
194
213
|
You can use a block to specify a complex attribute value
|
|
195
214
|
|
|
196
215
|
```ruby
|
|
@@ -206,6 +225,8 @@ class Contact < ActiveRecord::Base
|
|
|
206
225
|
end
|
|
207
226
|
```
|
|
208
227
|
|
|
228
|
+
#### Custom ```objectID```
|
|
229
|
+
|
|
209
230
|
By default, the `objectID` is based on your record's `id`. You can change this behavior specifying the `:id` option (be sure to use a uniq field).
|
|
210
231
|
|
|
211
232
|
```ruby
|
|
@@ -217,6 +238,8 @@ class UniqUser < ActiveRecord::Base
|
|
|
217
238
|
end
|
|
218
239
|
```
|
|
219
240
|
|
|
241
|
+
#### Restrict indexing to a subset of your data
|
|
242
|
+
|
|
220
243
|
You can add constraints controlling if a record must be indexed by using options the ```:if``` or ```:unless``` options.
|
|
221
244
|
|
|
222
245
|
```ruby
|
|
@@ -320,6 +343,8 @@ end
|
|
|
320
343
|
Indexing
|
|
321
344
|
---------
|
|
322
345
|
|
|
346
|
+
#### Manual indexing
|
|
347
|
+
|
|
323
348
|
You can trigger indexing using the <code>index!</code> instance method.
|
|
324
349
|
|
|
325
350
|
```ruby
|
|
@@ -327,6 +352,8 @@ c = Contact.create!(params[:contact])
|
|
|
327
352
|
c.index!
|
|
328
353
|
```
|
|
329
354
|
|
|
355
|
+
#### Manual removal
|
|
356
|
+
|
|
330
357
|
And trigger index removing using the <code>remove_from_index!</code> instance method.
|
|
331
358
|
|
|
332
359
|
```ruby
|
|
@@ -334,6 +361,8 @@ c.remove_from_index!
|
|
|
334
361
|
c.destroy
|
|
335
362
|
```
|
|
336
363
|
|
|
364
|
+
#### Reindexing
|
|
365
|
+
|
|
337
366
|
To *safely* reindex all your records (index to a temporary index + move the temporary index to the current one atomically), use the <code>reindex</code> class method:
|
|
338
367
|
|
|
339
368
|
```ruby
|
|
@@ -346,6 +375,8 @@ To reindex all your records (in place, without deleting out-dated records), use
|
|
|
346
375
|
Contact.reindex!
|
|
347
376
|
```
|
|
348
377
|
|
|
378
|
+
#### Clearing an index
|
|
379
|
+
|
|
349
380
|
To clear an index, use the <code>clear_index!</code> class method:
|
|
350
381
|
|
|
351
382
|
```ruby
|
|
@@ -450,6 +481,8 @@ At query time, specify <code>{ tagFilters: 'tagvalue' }</code> or <code>{ tagFil
|
|
|
450
481
|
Search
|
|
451
482
|
----------
|
|
452
483
|
|
|
484
|
+
***Notes:*** We recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-js) to perform queries directly from the end-user browser without going through your server.
|
|
485
|
+
|
|
453
486
|
A search returns ORM-compliant objects reloading them from your database. We recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-js) to perform queries to decrease the overall latency and offload your servers.
|
|
454
487
|
|
|
455
488
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.10.
|
|
1
|
+
1.10.8
|
data/algoliasearch-rails.gemspec
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "algoliasearch-rails"
|
|
9
|
-
s.version = "1.10.
|
|
9
|
+
s.version = "1.10.8"
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.authors = ["Algolia"]
|
|
13
|
-
s.date = "2014-07
|
|
13
|
+
s.date = "2014-08-07"
|
|
14
14
|
s.description = "AlgoliaSearch integration to your favorite ORM"
|
|
15
15
|
s.email = "contact@algolia.com"
|
|
16
16
|
s.extra_rdoc_files = [
|
data/lib/algoliasearch-rails.rb
CHANGED
|
@@ -357,7 +357,12 @@ module AlgoliaSearch
|
|
|
357
357
|
end
|
|
358
358
|
json = algolia_raw_search(q, params)
|
|
359
359
|
hit_ids = json['hits'].map { |hit| hit['objectID'] }
|
|
360
|
-
|
|
360
|
+
if defined?(::Mongoid::Document) && self.include?(::Mongoid::Document)
|
|
361
|
+
condition_key = algolia_object_id_method.in
|
|
362
|
+
else
|
|
363
|
+
condition_key = algolia_object_id_method
|
|
364
|
+
end
|
|
365
|
+
results_by_id = algoliasearch_options[:type].where(condition_key => hit_ids).index_by do |hit|
|
|
361
366
|
algolia_object_id_of(hit)
|
|
362
367
|
end
|
|
363
368
|
results = json['hits'].map do |hit|
|
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.10.
|
|
4
|
+
version: 1.10.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Algolia
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-07
|
|
11
|
+
date: 2014-08-07 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: json
|
|
@@ -140,10 +140,10 @@ files:
|
|
|
140
140
|
- spec/utilities_spec.rb
|
|
141
141
|
- vendor/assets/javascripts/algolia/algoliasearch.js
|
|
142
142
|
- vendor/assets/javascripts/algolia/algoliasearch.min.js
|
|
143
|
-
- vendor/assets/javascripts/algolia/
|
|
143
|
+
- vendor/assets/javascripts/algolia/bloodhound.js
|
|
144
144
|
- vendor/assets/javascripts/algolia/typeahead.bundle.js
|
|
145
145
|
- vendor/assets/javascripts/algolia/typeahead.bundle.min.js
|
|
146
|
-
- vendor/assets/javascripts/algolia/
|
|
146
|
+
- vendor/assets/javascripts/algolia/typeahead.jquery.js
|
|
147
147
|
homepage: http://github.com/algolia/algoliasearch-rails
|
|
148
148
|
licenses:
|
|
149
149
|
- MIT
|
|
@@ -164,7 +164,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
164
164
|
version: '0'
|
|
165
165
|
requirements: []
|
|
166
166
|
rubyforge_project:
|
|
167
|
-
rubygems_version: 2.
|
|
167
|
+
rubygems_version: 2.2.2
|
|
168
168
|
signing_key:
|
|
169
169
|
specification_version: 4
|
|
170
170
|
summary: AlgoliaSearch integration to your favorite ORM
|