algoliasearch-rails 1.16.3 → 1.17.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +8 -0
  3. data/Gemfile +6 -1
  4. data/Gemfile.lock +3 -3
  5. data/README.md +153 -94
  6. data/VERSION +1 -1
  7. data/algoliasearch-rails.gemspec +1 -1
  8. data/lib/algoliasearch-rails.rb +75 -36
  9. data/spec/spec_helper.rb +7 -0
  10. data/vendor/assets/javascripts/algolia/algoliasearch.angular.js +23 -12
  11. data/vendor/assets/javascripts/algolia/algoliasearch.angular.min.js +2 -2
  12. data/vendor/assets/javascripts/algolia/algoliasearch.jquery.js +23 -12
  13. data/vendor/assets/javascripts/algolia/algoliasearch.jquery.min.js +2 -2
  14. data/vendor/assets/javascripts/algolia/algoliasearch.js +22 -12
  15. data/vendor/assets/javascripts/algolia/algoliasearch.min.js +2 -2
  16. data/vendor/assets/javascripts/algolia/v2/algoliasearch.angular.js +23 -12
  17. data/vendor/assets/javascripts/algolia/v2/algoliasearch.angular.min.js +2 -2
  18. data/vendor/assets/javascripts/algolia/v2/algoliasearch.jquery.js +23 -12
  19. data/vendor/assets/javascripts/algolia/v2/algoliasearch.jquery.min.js +2 -2
  20. data/vendor/assets/javascripts/algolia/v2/algoliasearch.js +22 -12
  21. data/vendor/assets/javascripts/algolia/v2/algoliasearch.min.js +2 -2
  22. data/vendor/assets/javascripts/algolia/v3/algoliasearch.angular.js +2020 -1301
  23. data/vendor/assets/javascripts/algolia/v3/algoliasearch.angular.min.js +3 -3
  24. data/vendor/assets/javascripts/algolia/v3/algoliasearch.jquery.js +2019 -1300
  25. data/vendor/assets/javascripts/algolia/v3/algoliasearch.jquery.min.js +3 -3
  26. data/vendor/assets/javascripts/algolia/v3/algoliasearch.js +2003 -1284
  27. data/vendor/assets/javascripts/algolia/v3/algoliasearch.min.js +3 -3
  28. metadata +5 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 52de41878cc41dc76652c65d5756e3a7bd4388ef
4
- data.tar.gz: fa59514cb2befd16b72e20fa99a324d17ed90eef
3
+ metadata.gz: 8cb64784062fdd3807e7188dee376b0a885e96c1
4
+ data.tar.gz: c96b2d0c53e20bcfe60ffe54a91a2ab5337e2c9f
5
5
  SHA512:
6
- metadata.gz: 6a63d43c7956d7bed29fe961eeff363f873848c2a6040599ac71764eebf0919b26ddade734b2dcb6992fd862b5e5592dc66286673884a9c7d9d206ae7ed7ba1c
7
- data.tar.gz: 59d339a85f0120d75a7392878fbec5dfa02eec4e182c182a1c59168b729d20e0ce658e8c6fad36652a474a13fb58f5922e887feffc85cd0142e2616535589464
6
+ metadata.gz: d23d7614758097f7b4d564346df34d0ada721b06762dd602389b63836fde982df35b2da6e6bfaa710674f2389e56813b5fa9d498de015c118079d99eba2b33a1
7
+ data.tar.gz: 0eebeb346a1b02a173edd743489e9414dba113b6c3ee4010e634b96aa207164c0adbe582b1eb647a173d8b1905360f5e9099db00993a65d724ffd119a4c5dee8
data/ChangeLog CHANGED
@@ -1,5 +1,13 @@
1
1
  CHANGELOG
2
2
 
3
+ 2017-01-05 1.17.0
4
+
5
+ * Do not enqueue indexing operations if the indexing is disabled
6
+ * Add `searchableAttributes` and `numericAttributesForFiltering` index settings
7
+ * Fixed here and there synchronous behaviors (mostly unit tests related)
8
+ * Rename `slave` to `replica`
9
+ * Upgraded `algoliasearch-client-{ruby,js}` deps
10
+
3
11
  2016-11-25 1.16.3
4
12
 
5
13
  * Propagate `search_facet` to `search_for_facet_values` renaming (backward compatible)
data/Gemfile CHANGED
@@ -1,7 +1,7 @@
1
1
  source "http://rubygems.org"
2
2
 
3
3
  gem 'json', '~> 1.5', '>= 1.5.1'
4
- gem 'algoliasearch', '~> 1.12.1'
4
+ gem 'algoliasearch', '~> 1.12.4'
5
5
  gem 'rubysl', '~> 2.0', :platform => :rbx
6
6
 
7
7
  group :test do
@@ -14,9 +14,14 @@ group :test do
14
14
  gem 'rack-cache', '< 1.3'
15
15
  gem 'mime-types', '< 2.6'
16
16
  gem 'net-http-persistent', '< 3.0'
17
+ gem 'faraday', '< 0.10'
17
18
  elsif defined?(RUBY_VERSION) && RUBY_VERSION == "1.9.3"
19
+ gem 'rack', '< 2'
20
+ gem 'nokogiri', '< 1.7.0'
18
21
  if Gem::Version.new(ENV['RAILS_VERSION'] || '3.2.0') >= Gem::Version.new('4.0')
19
22
  gem 'mime-types', '~> 2.6'
23
+ else
24
+ gem 'mime-types', '< 3'
20
25
  end
21
26
  end
22
27
  if defined?(RUBY_VERSION) &&
data/Gemfile.lock CHANGED
@@ -39,7 +39,7 @@ GEM
39
39
  minitest (~> 5.1)
40
40
  tzinfo (~> 1.1)
41
41
  addressable (2.4.0)
42
- algoliasearch (1.12.0)
42
+ algoliasearch (1.12.4)
43
43
  httpclient (~> 2.8.2.4)
44
44
  json (>= 1.5.1)
45
45
  arel (7.1.0)
@@ -372,7 +372,7 @@ PLATFORMS
372
372
  DEPENDENCIES
373
373
  activerecord-jdbc-adapter
374
374
  activerecord-jdbcsqlite3-adapter
375
- algoliasearch (~> 1.12.0)
375
+ algoliasearch (~> 1.12.4)
376
376
  jdbc-sqlite3
377
377
  json (~> 1.5, >= 1.5.1)
378
378
  kaminari
@@ -388,4 +388,4 @@ DEPENDENCIES
388
388
  will_paginate (>= 2.3.15)
389
389
 
390
390
  BUNDLED WITH
391
- 1.12.5
391
+ 1.13.6
data/README.md CHANGED
@@ -1,9 +1,6 @@
1
- <!--NO_HTML-->
1
+ # Algolia Search API Client for Rails
2
2
 
3
- Algolia Search for Rails
4
- ==================
5
-
6
- <!--/NO_HTML-->
3
+ [Algolia Search](https://www.algolia.com) is a hosted full-text, numerical, and faceted search engine capable of delivering realtime results from the first keystroke.
7
4
 
8
5
  This gem let you easily integrate the Algolia Search API to your favorite ORM. It's based on the [algoliasearch-client-ruby](https://github.com/algolia/algoliasearch-client-ruby) gem. Rails 3.x, 4.x and 5.x are all supported.
9
6
 
@@ -11,34 +8,89 @@ You might be interested in the sample Ruby on Rails application providing a `aut
11
8
 
12
9
  [![Build Status](https://travis-ci.org/algolia/algoliasearch-rails.svg?branch=master)](https://travis-ci.org/algolia/algoliasearch-rails) [![Gem Version](https://badge.fury.io/rb/algoliasearch-rails.svg)](http://badge.fury.io/rb/algoliasearch-rails) [![Code Climate](https://codeclimate.com/github/algolia/algoliasearch-rails.svg)](https://codeclimate.com/github/algolia/algoliasearch-rails) ![ActiveRecord](https://img.shields.io/badge/ActiveRecord-yes-blue.svg?style=flat-square) ![Mongoid](https://img.shields.io/badge/Mongoid-yes-blue.svg?style=flat-square) ![Sequel](https://img.shields.io/badge/Sequel-yes-blue.svg?style=flat-square)
13
10
 
14
- <!--NO_HTML-->
15
11
 
16
- Table of Content
17
- =============
12
+ # Table of Contents
13
+
14
+
15
+ **Setup**
18
16
 
19
17
  1. [Install](#install)
20
- 1. [Setup](#setup)
21
- 1. [Quick Start](#quick-start)
22
- 1. [Options](#options)
23
- 1. [Configuration example](#configuration-example)
18
+ 1. [Configuration](#configuration)
19
+
20
+ **Quick Start**
21
+
22
+ 1. [Schema](#schema)
23
+ 1. [Relevancy](#relevancy)
24
24
  1. [Indexing](#indexing)
25
- 1. [Master/Slave](#masterslave)
25
+ 1. [Frontend Search (realtime experience)](#frontend-search-realtime-experience)
26
+ 1. [Backend Search](#backend-search)
27
+ 1. [Backend Pagination](#backend-pagination)
28
+ 1. [Notes](#notes)
29
+
30
+ **Options**
31
+
32
+ 1. [Auto-indexing &amp; asynchronism](#auto-indexing--asynchronism)
33
+ 1. [Exceptions](#exceptions)
34
+ 1. [Custom index name](#custom-index-name)
35
+ 1. [Per-environment indexes](#per-environment-indexes)
36
+ 1. [Custom attribute definition](#custom-attribute-definition)
37
+ 1. [Nested objects/relations](#nested-objectsrelations)
38
+ 1. [Custom `objectID`](#custom-objectid)
39
+ 1. [Restrict indexing to a subset of your data](#restrict-indexing-to-a-subset-of-your-data)
40
+ 1. [Sanitizer](#sanitizer)
41
+ 1. [UTF-8 Encoding](#utf-8-encoding)
42
+ 1. [Configuration example](#configuration-example)
43
+
44
+ **Indexing**
45
+
46
+ 1. [Manual indexing](#manual-indexing)
47
+ 1. [Manual removal](#manual-removal)
48
+ 1. [Reindexing](#reindexing)
49
+ 1. [Clearing an index](#clearing-an-index)
50
+ 1. [Using the underlying index](#using-the-underlying-index)
51
+
52
+ **Indexes**
53
+
54
+ 1. [Primary/replica](#primaryreplica)
26
55
  1. [Share a single index](#share-a-single-index)
27
56
  1. [Target multiple indexes](#target-multiple-indexes)
57
+
58
+ **Features**
59
+
28
60
  1. [Tags](#tags)
29
61
  1. [Search](#search)
30
62
  1. [Faceting](#faceting)
31
63
  1. [Facet search](#facet-search)
32
64
  1. [Group by](#group-by)
33
- 1. [Geo-search](#geo-search)
65
+ 1. [Geo-Search](#geo-search)
34
66
  1. [Caveats](#caveats)
67
+ 1. [Timeouts](#timeouts)
35
68
  1. [Note on testing](#note-on-testing)
36
69
 
37
- <!--/NO_HTML-->
38
70
 
39
- ## Setup
71
+ # Guides & Tutorials
72
+
73
+ Check our [online guides](https://www.algolia.com/doc):
74
+
75
+ * [Data Formatting](https://www.algolia.com/doc/indexing/formatting-your-data)
76
+ * [Import and Synchronize data](https://www.algolia.com/doc/indexing/import-synchronize-data/php)
77
+ * [Autocomplete](https://www.algolia.com/doc/search/auto-complete)
78
+ * [Instant search page](https://www.algolia.com/doc/search/instant-search)
79
+ * [Filtering and Faceting](https://www.algolia.com/doc/search/filtering-faceting)
80
+ * [Sorting](https://www.algolia.com/doc/relevance/sorting)
81
+ * [Ranking Formula](https://www.algolia.com/doc/relevance/ranking)
82
+ * [Typo-Tolerance](https://www.algolia.com/doc/relevance/typo-tolerance)
83
+ * [Geo-Search](https://www.algolia.com/doc/geo-search/geo-search-overview)
84
+ * [Security](https://www.algolia.com/doc/security/best-security-practices)
85
+ * [API-Keys](https://www.algolia.com/doc/security/api-keys)
86
+ * [REST API](https://www.algolia.com/doc/rest)
87
+
88
+
89
+ # Setup
40
90
 
41
- ### Install
91
+
92
+
93
+ ## Install
42
94
 
43
95
  ```sh
44
96
  gem install algoliasearch-rails
@@ -56,20 +108,22 @@ And run:
56
108
  bundle install
57
109
  ```
58
110
 
59
- ### Configuration
111
+ ## Configuration
60
112
 
61
113
  Create a new file <code>config/initializers/algoliasearch.rb</code> to setup your <code>APPLICATION_ID</code> and <code>API_KEY</code>.
62
114
 
63
-
64
115
  ```ruby
65
116
  AlgoliaSearch.configuration = { application_id: 'YourApplicationID', api_key: 'YourAPIKey' }
66
117
  ```
67
118
 
68
119
  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).
69
120
 
70
- ## Quick Start
71
121
 
72
- ### Schema
122
+ # Quick Start
123
+
124
+
125
+
126
+ ## Schema
73
127
 
74
128
  The following code will create a <code>Contact</code> index and add search capabilities to your <code>Contact</code> model:
75
129
 
@@ -112,7 +166,7 @@ class Product < ActiveRecord::Base
112
166
  end
113
167
  ```
114
168
 
115
- ### Relevancy
169
+ ## Relevancy
116
170
 
117
171
  We provide many ways to configure your index allowing you to tune your overall index relevancy. The most important ones are the **searchable attributes** and the attributes reflecting **record popularity**.
118
172
 
@@ -124,11 +178,11 @@ class Product < ActiveRecord::Base
124
178
  # list of attribute used to build an Algolia record
125
179
  attributes :title, :subtitle, :description, :likes_count, :seller_name
126
180
 
127
- # the attributesToIndex` setting defines the attributes
181
+ # the `searchableAttributes` (formerly known as attributesToIndex) setting defines the attributes
128
182
  # you want to search in: here `title`, `subtitle` & `description`.
129
183
  # You need to list them by order of importance. `description` is tagged as
130
184
  # `unordered` to avoid taking the position of a match into account in that attribute.
131
- attributesToIndex ['title', 'subtitle', 'unordered(description)']
185
+ searchableAttributes ['title', 'subtitle', 'unordered(description)']
132
186
 
133
187
  # the `customRanking` setting defines the ranking criteria use to compare two matching
134
188
  # records in case their text-relevance is equal. It should reflect your record popularity.
@@ -138,7 +192,7 @@ class Product < ActiveRecord::Base
138
192
  end
139
193
  ```
140
194
 
141
- ### Indexing
195
+ ## Indexing
142
196
 
143
197
  To index a model, simple call `reindex` on the class:
144
198
 
@@ -156,11 +210,11 @@ algolia_models = ActiveRecord::Base.descendants.select{ |model| model.respond_to
156
210
  algolia_models.each(&:reindex)
157
211
  ```
158
212
 
159
- ### Frontend Search (realtime experience)
213
+ ## Frontend Search (realtime experience)
160
214
 
161
215
  Traditional search implementations tend to have search logic and functionality on the backend. This made sense when the search experience consisted of a user entering a search query, executing that search, and then being redirected to a search result page.
162
216
 
163
- Implementing search on the backend is no longer necessary. In fact, in most cases it is harmful to performance because of added network and processing latency. We highly recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-js) issuing all search requests directly from the end user's browser, mobile device, or client. It will reduce the overall search latency while offloading your servers at the same time.
217
+ Implementing search on the backend is no longer necessary. In fact, in most cases it is harmful to performance because of added network and processing latency. We highly recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-javascript) issuing all search requests directly from the end user's browser, mobile device, or client. It will reduce the overall search latency while offloading your servers at the same time.
164
218
 
165
219
  The JS API client is part of the gem, just require `algolia/v3/algoliasearch.min` somewhere in your JavaScript manifest, for example in `application.js` if you are using Rails 3.1+:
166
220
 
@@ -182,9 +236,9 @@ index.search('something', { hitsPerPage: 10, page: 0 })
182
236
  });
183
237
  ```
184
238
 
185
- **We recently (March 2015) released a new version (V3) of our JavaScript client, if you were using our previous version (V2), [read the migration guide](https://github.com/algolia/algoliasearch-client-js/wiki/Migration-guide-from-2.x.x-to-3.x.x)**
239
+ **We recently (March 2015) released a new version (V3) of our JavaScript client, if you were using our previous version (V2), [read the migration guide](https://github.com/algolia/algoliasearch-client-javascript/wiki/Migration-guide-from-2.x.x-to-3.x.x)**
186
240
 
187
- ### Backend Search
241
+ ## Backend Search
188
242
 
189
243
  If you want to search from your backend you can use the `raw_search` method. It retrieves the raw JSON answer from the API:
190
244
 
@@ -198,7 +252,7 @@ You could also use `search` but it's not recommended. This method will fetch the
198
252
  p Contact.search("jon doe") # we recommend to use `raw_search` to avoid the database lookup
199
253
  ```
200
254
 
201
- ### Backend Pagination
255
+ ## Backend Pagination
202
256
 
203
257
  Even if we **highly recommend to perform all search (and therefore pagination) operations from your frontend using JavaScript**, we support both [will_paginate](https://github.com/mislav/will_paginate) and [kaminari](https://github.com/amatsuda/kaminari) as pagination backend.
204
258
 
@@ -222,7 +276,7 @@ Then, as soon as you use the `search` method, the returning results will be a pa
222
276
  <%= paginate @results %>
223
277
  ```
224
278
 
225
- ### Notes
279
+ ## Notes
226
280
 
227
281
  All methods injected by the `AlgoliaSearch` include are prefixed by `algolia_` and aliased to the associated short names if they aren't already defined.
228
282
 
@@ -232,9 +286,12 @@ Contact.algolia_reindex! # <=> Contact.reindex!
232
286
  Contact.algolia_search("jon doe") # <=> Contact.search("jon doe")
233
287
  ```
234
288
 
235
- ## Options
236
289
 
237
- ### Auto-indexing & asynchronism
290
+ # Options
291
+
292
+
293
+
294
+ ## Auto-indexing & asynchronism
238
295
 
239
296
  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. That means that a network call with the ADD/DELETE operation is sent **synchronously** to the Algolia API but then the engine will **asynchronously** process the operation (so if you do a search just after, the results may not reflect it yet).
240
297
 
@@ -250,7 +307,7 @@ class Contact < ActiveRecord::Base
250
307
  end
251
308
  ```
252
309
 
253
- #### Temporary disable auto-indexing
310
+ ### Temporary disable auto-indexing
254
311
 
255
312
  You can temporary disable auto-indexing using the <code>without_auto_index</code> scope. This is often used for performance reason.
256
313
 
@@ -262,7 +319,7 @@ end
262
319
  Contact.reindex! # will use batch operations
263
320
  ```
264
321
 
265
- #### Queues & background jobs
322
+ ### Queues & background jobs
266
323
 
267
324
  You can configure the auto-indexing & auto-removal process to use a queue to perform those operations in background. ActiveJob (Rails >=4.2) queues are used by default but you can define your own queuing mechanism:
268
325
 
@@ -276,7 +333,7 @@ class Contact < ActiveRecord::Base
276
333
  end
277
334
  ```
278
335
 
279
- #### Things to Consider
336
+ ### Things to Consider
280
337
 
281
338
  If you are performing updates & deletions in the background then a record deletion can be committed to your database prior
282
339
  to the job actually executing. Thus if you were to load the record to remove it from the database than your ActiveRecord#find will fail with a RecordNotFound.
@@ -300,7 +357,7 @@ class MySidekiqWorker
300
357
  end
301
358
  ```
302
359
 
303
- #### With Sidekiq
360
+ ### With Sidekiq
304
361
 
305
362
  If you're using [Sidekiq](https://github.com/mperham/sidekiq):
306
363
 
@@ -325,7 +382,7 @@ class MySidekiqWorker
325
382
  end
326
383
  ```
327
384
 
328
- #### With DelayedJob
385
+ ### With DelayedJob
329
386
 
330
387
  If you're using [delayed_job](https://github.com/collectiveidea/delayed_job):
331
388
 
@@ -348,7 +405,7 @@ end
348
405
 
349
406
  ```
350
407
 
351
- #### Synchronism & testing
408
+ ### Synchronism & testing
352
409
 
353
410
  You can force indexing and removing to be synchronous (in that case the gem will call the `wait_task` method to ensure the operation has been taken into account once the method returns) by setting the following option: (this is **NOT** recommended, except for testing purpose)
354
411
 
@@ -362,7 +419,7 @@ class Contact < ActiveRecord::Base
362
419
  end
363
420
  ```
364
421
 
365
- ### Exceptions
422
+ ## Exceptions
366
423
 
367
424
  You can disable exceptions that could be raised while trying to reach Algolia's API by using the `raise_on_failure` option:
368
425
 
@@ -377,7 +434,7 @@ class Contact < ActiveRecord::Base
377
434
  end
378
435
  ```
379
436
 
380
- ### Custom index name
437
+ ## Custom index name
381
438
 
382
439
  By default, the index name will be the class name, e.g. "Contact". You can customize the index name by using the `index_name` option:
383
440
 
@@ -391,7 +448,7 @@ class Contact < ActiveRecord::Base
391
448
  end
392
449
  ```
393
450
 
394
- ### Per-environment indexes
451
+ ## Per-environment indexes
395
452
 
396
453
  You can suffix the index name with the current Rails environment using the following option:
397
454
 
@@ -405,7 +462,7 @@ class Contact < ActiveRecord::Base
405
462
  end
406
463
  ```
407
464
 
408
- ### Custom attribute definition
465
+ ## Custom attribute definition
409
466
 
410
467
  You can use a block to specify a complex attribute value
411
468
 
@@ -446,7 +503,7 @@ class Contact < ActiveRecord::Base
446
503
  end
447
504
  ```
448
505
 
449
- ### Nested objects/relations
506
+ ## Nested objects/relations
450
507
 
451
508
  You can easily embed nested objects defining an extra attribute returning any JSON-compliant object (an array or a hash or a combination of both).
452
509
 
@@ -473,7 +530,7 @@ class Profile < ActiveRecord::Base
473
530
  end
474
531
  ```
475
532
 
476
- ### Custom `objectID`
533
+ ## Custom `objectID`
477
534
 
478
535
  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).
479
536
 
@@ -486,7 +543,7 @@ class UniqUser < ActiveRecord::Base
486
543
  end
487
544
  ```
488
545
 
489
- ### Restrict indexing to a subset of your data
546
+ ## Restrict indexing to a subset of your data
490
547
 
491
548
  You can add constraints controlling if a record must be indexed by using options the `:if` or `:unless` options.
492
549
 
@@ -528,7 +585,6 @@ class Contact < ActiveRecord::Base
528
585
  end
529
586
  ```
530
587
 
531
-
532
588
  You can index a subset of your records using either:
533
589
 
534
590
  ```ruby
@@ -542,7 +598,7 @@ or
542
598
  MyModel.index_objects MyModel.limit(5)
543
599
  ```
544
600
 
545
- ### Sanitizer
601
+ ## Sanitizer
546
602
 
547
603
  You can sanitize all your attributes using the `sanitize` option. It will strip all HTML tags from your attributes.
548
604
 
@@ -563,8 +619,7 @@ If you're using Rails 4.2+, you also need to depend on `rails-html-sanitizer`:
563
619
  gem 'rails-html-sanitizer'
564
620
  ```
565
621
 
566
-
567
- ### UTF-8 Encoding
622
+ ## UTF-8 Encoding
568
623
 
569
624
  You can force the UTF-8 encoding of all your attributes using the `force_utf8_encoding` option:
570
625
 
@@ -581,8 +636,7 @@ end
581
636
 
582
637
  ***Notes:*** This option is not compatible with Ruby 1.8
583
638
 
584
-
585
- ### Configuration example
639
+ ## Configuration example
586
640
 
587
641
  Here is a real-word configuration example (from [HN Search](https://github.com/algolia/hn-search)):
588
642
 
@@ -601,7 +655,7 @@ class Item < ActiveRecord::Base
601
655
 
602
656
  # `title` is more important than `{story,comment}_text`, `{story,comment}_text` more than `url`, `url` more than `author`
603
657
  # btw, do not take into account position in most fields to avoid first word match boost
604
- attributesToIndex ['unordered(title)', 'unordered(story_text)', 'unordered(comment_text)', 'unordered(url)', 'author']
658
+ searchableAttributes ['unordered(title)', 'unordered(story_text)', 'unordered(comment_text)', 'unordered(url)', 'author']
605
659
 
606
660
  # tags used for filtering
607
661
  tags do
@@ -639,9 +693,12 @@ class Item < ActiveRecord::Base
639
693
  end
640
694
  ```
641
695
 
642
- ## Indexing
643
696
 
644
- ### Manual indexing
697
+ # Indexing
698
+
699
+
700
+
701
+ ## Manual indexing
645
702
 
646
703
  You can trigger indexing using the <code>index!</code> instance method.
647
704
 
@@ -650,7 +707,7 @@ c = Contact.create!(params[:contact])
650
707
  c.index!
651
708
  ```
652
709
 
653
- ### Manual removal
710
+ ## Manual removal
654
711
 
655
712
  And trigger index removing using the <code>remove_from_index!</code> instance method.
656
713
 
@@ -659,11 +716,11 @@ c.remove_from_index!
659
716
  c.destroy
660
717
  ```
661
718
 
662
- ### Reindexing
719
+ ## Reindexing
663
720
 
664
721
  The gem provides 2 ways to reindex all your objects:
665
722
 
666
- #### Atomical reindexing
723
+ ### Atomical reindexing
667
724
 
668
725
  To reindex all your records (taking into account the deleted objects), the `reindex` class method indexes all your objects to a temporary index called `<INDEX_NAME>.tmp` and moves the temporary index to the final one once everything is indexed (atomically). This is the safest way to reindex all your content.
669
726
 
@@ -673,7 +730,7 @@ Contact.reindex
673
730
 
674
731
  **Notes**: if you're using an index-specific API key, ensure you're allowing both `<INDEX_NAME>` and `<INDEX_NAME>.tmp`.
675
732
 
676
- #### Regular reindexing
733
+ ### Regular reindexing
677
734
 
678
735
  To reindex all your objects in place (without temporary index and therefore without deleting removed objects), use the `reindex!` class method:
679
736
 
@@ -681,7 +738,7 @@ To reindex all your objects in place (without temporary index and therefore with
681
738
  Contact.reindex!
682
739
  ```
683
740
 
684
- ### Clearing an index
741
+ ## Clearing an index
685
742
 
686
743
  To clear an index, use the <code>clear_index!</code> class method:
687
744
 
@@ -689,7 +746,7 @@ To clear an index, use the <code>clear_index!</code> class method:
689
746
  Contact.clear_index!
690
747
  ```
691
748
 
692
- ### Using the underlying index
749
+ ## Using the underlying index
693
750
 
694
751
  You can access the underlying `index` object by calling the `index` class method:
695
752
 
@@ -698,11 +755,13 @@ index = Contact.index
698
755
  # index.get_settings, index.partial_update_object, ...
699
756
  ```
700
757
 
701
- ## Indexes
702
758
 
703
- ### Master/slave
759
+ # Indexes
760
+
761
+
762
+ ## Primary/replica
704
763
 
705
- You can define slave indexes using the <code>add_slave</code> method:
764
+ You can define replica indices using the <code>add_replica</code> method:
706
765
 
707
766
  ```ruby
708
767
  class Book < ActiveRecord::Base
@@ -711,31 +770,31 @@ class Book < ActiveRecord::Base
711
770
  include AlgoliaSearch
712
771
 
713
772
  algoliasearch per_environment: true do
714
- attributesToIndex [:name, :author, :editor]
773
+ searchableAttributes [:name, :author, :editor]
715
774
 
716
- # define a slave index to search by `author` only
717
- add_slave 'Book_by_author', per_environment: true do
718
- attributesToIndex [:author]
775
+ # define a replica index to search by `author` only
776
+ add_replica 'Book_by_author', per_environment: true do
777
+ searchableAttributes [:author]
719
778
  end
720
779
 
721
- # define a slave index to search by `editor` only
722
- add_slave 'Book_by_editor', per_environment: true do
723
- attributesToIndex [:editor]
780
+ # define a replica index to search by `editor` only
781
+ add_replica 'Book_by_editor', per_environment: true do
782
+ searchableAttributes [:editor]
724
783
  end
725
784
  end
726
785
 
727
786
  end
728
787
  ```
729
788
 
730
- To search using a slave, use the following code:
789
+ To search using a replica, use the following code:
731
790
 
732
791
  ```ruby
733
- Book.raw_search 'foo bar', slave: 'Book_by_editor'
792
+ Book.raw_search 'foo bar', replica: 'Book_by_editor'
734
793
  # or
735
- Book.search 'foo bar', slave: 'Book_by_editor'
794
+ Book.search 'foo bar', replica: 'Book_by_editor'
736
795
  ```
737
796
 
738
- ### Share a single index
797
+ ## Share a single index
739
798
 
740
799
  It can make sense to share an index between several models. In order to implement that, you'll need to ensure you don't have any conflict with the `objectID` of the underlying models.
741
800
 
@@ -773,7 +832,7 @@ end
773
832
 
774
833
  ***Notes:*** If you target a single index from several models, you must never use `MyModel.reindex` and only use `MyModel.reindex!`. The `reindex` method uses a temporary index to perform an atomic reindexing: if you use it, the resulting index will only contain records for the current model because it will not reindex the others.
775
834
 
776
- ### Target multiple indexes
835
+ ## Target multiple indexes
777
836
 
778
837
  You can index a record in several indexes using the <code>add_index</code> method:
779
838
 
@@ -788,7 +847,7 @@ class Book < ActiveRecord::Base
788
847
 
789
848
  # store all books in index 'SECURED_INDEX_NAME'
790
849
  algoliasearch index_name: SECURED_INDEX_NAME do
791
- attributesToIndex [:name, :author]
850
+ searchableAttributes [:name, :author]
792
851
  # convert security to tags
793
852
  tags do
794
853
  [released ? 'public' : 'private', premium ? 'premium' : 'standard']
@@ -796,7 +855,7 @@ class Book < ActiveRecord::Base
796
855
 
797
856
  # store all 'public' (released and not premium) books in index 'PUBLIC_INDEX_NAME'
798
857
  add_index PUBLIC_INDEX_NAME, if: :public? do
799
- attributesToIndex [:name, :author]
858
+ searchableAttributes [:name, :author]
800
859
  end
801
860
  end
802
861
 
@@ -816,9 +875,12 @@ Book.raw_search 'foo bar', index: 'Book_by_editor'
816
875
  Book.search 'foo bar', index: 'Book_by_editor'
817
876
  ```
818
877
 
819
- ## Features
820
878
 
821
- ### Tags
879
+ # Features
880
+
881
+
882
+
883
+ ## Tags
822
884
 
823
885
  Use the <code>tags</code> method to add tags to your record:
824
886
 
@@ -848,12 +910,11 @@ end
848
910
 
849
911
  At query time, specify <code>{ tagFilters: 'tagvalue' }</code> or <code>{ tagFilters: ['tagvalue1', 'tagvalue2'] }</code> as search parameters to restrict the result set to specific tags.
850
912
 
851
- ### Search
913
+ ## Search
852
914
 
853
- ***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.
854
-
855
- 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.
915
+ ***Notes:*** We recommend the usage of our [JavaScript API Client](https://github.com/algolia/algoliasearch-client-javascript) to perform queries directly from the end-user browser without going through your server.
856
916
 
917
+ 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-javascript) to perform queries to decrease the overall latency and offload your servers.
857
918
 
858
919
  ```ruby
859
920
  hits = Contact.search("jon doe")
@@ -893,13 +954,12 @@ class Contact < ActiveRecord::Base
893
954
  end
894
955
  ```
895
956
 
896
-
897
957
  ```ruby
898
958
  # dynamical search parameters
899
959
  p Contact.raw_search("jon doe", { :hitsPerPage => 5, :page => 2 })
900
960
  ```
901
961
 
902
- ### Faceting
962
+ ## Faceting
903
963
 
904
964
  Facets can be retrieved calling the extra `facets` method of the search answer.
905
965
 
@@ -916,7 +976,6 @@ class Contact < ActiveRecord::Base
916
976
  end
917
977
  ```
918
978
 
919
-
920
979
  ```ruby
921
980
  hits = Contact.search("jon doe", { :facets => '*' })
922
981
  p hits # ORM-compliant array of objects
@@ -925,13 +984,12 @@ p hits.facets['company'] # facet values+count of facet 'company'
925
984
  p hits.facets['zip_code'] # facet values+count of facet 'zip_code'
926
985
  ```
927
986
 
928
-
929
987
  ```ruby
930
988
  raw_json = Contact.raw_search("jon doe", { :facets => '*' })
931
989
  p raw_json['facets']
932
990
  ```
933
991
 
934
- ### Facet search
992
+ ## Facet search
935
993
 
936
994
  You can also search for facet values.
937
995
 
@@ -950,7 +1008,7 @@ Product.search_for_facet_values('category', 'phone', {
950
1008
  }) # Array of phone categories linked to red Apple products
951
1009
  ```
952
1010
 
953
- ### Group by
1011
+ ## Group by
954
1012
 
955
1013
  More info on distinct for grouping can be found
956
1014
  [here](https://www.algolia.com/doc/guides/search/distinct#distinct-for-grouping).
@@ -969,7 +1027,7 @@ class Contact < ActiveRecord::Base
969
1027
  end
970
1028
  ```
971
1029
 
972
- ### Geo-Search
1030
+ ## Geo-Search
973
1031
 
974
1032
  Use the <code>geoloc</code> method to localize your record:
975
1033
 
@@ -985,11 +1043,11 @@ end
985
1043
 
986
1044
  At query time, specify <code>{ aroundLatLng: "37.33, -121.89", aroundRadius: 50000 }</code> as search parameters to restrict the result set to 50KM around San Jose.
987
1045
 
988
- ### Caveats
1046
+ ## Caveats
989
1047
 
990
1048
  This gem makes intensive use of Rails' callbacks to trigger the indexing tasks. If you're using methods bypassing `after_validation`, `before_save` or `after_commit` callbacks, it will not index your changes. For example: `update_attribute` doesn't perform validations checks, to perform validations when updating use `update_attributes`.
991
1049
 
992
- ### Timeouts
1050
+ ## Timeouts
993
1051
 
994
1052
  You can configure a bunch of timeout threshold by setting the following options at initialization time:
995
1053
 
@@ -1005,7 +1063,7 @@ AlgoliaSearch.configuration = {
1005
1063
  }
1006
1064
  ```
1007
1065
 
1008
- ### Note on testing
1066
+ ## Note on testing
1009
1067
 
1010
1068
  To run the specs, please set the <code>ALGOLIA_APPLICATION_ID</code> and <code>ALGOLIA_API_KEY</code> environment variables. Since the tests are creating and removing indexes, DO NOT use your production account.
1011
1069
 
@@ -1050,3 +1108,4 @@ describe 'With a mocked client' do
1050
1108
  end
1051
1109
  ```
1052
1110
 
1111
+