algoliasearch-rails 1.10.4 → 1.10.6

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
  SHA1:
3
- metadata.gz: 7d6329550086f9eea99ae35aa6111fc515e8804c
4
- data.tar.gz: e5f7dc994433e9d927252a1b2c1c9b69e8fa18cc
3
+ metadata.gz: 0abd869d8b7021676051417ff8f3a54d64cd6c01
4
+ data.tar.gz: d84fbe3c59f997e518c27393b3c7b70d315c6c49
5
5
  SHA512:
6
- metadata.gz: 582679d281ba1dcddaa2ab478fb17129719d3c02013f8f0d6cc762b5bf488594a6a745ff754fa671b64d55557bfd9b5ffcba0de8762210fa2fe22d150e80f3cc
7
- data.tar.gz: 7237460c4e85f5e8f8178eeae72388098b77059ce1822c006e7d0c4c48c9b6128678963c4bac0baf5367b96a5639489eee606c0fee6f1d8c44c8554925b7a518
6
+ metadata.gz: f3023ccffd38aab0ad8f2bcf657fcdb1bfc027bc1b8fd78bd50184881f8e1cb25e24f318bc30ceb960d2d7421264f4c967385d8f08818749d4aac773f7cff725
7
+ data.tar.gz: 3286d414ed42da850ff3640c5f15d78296ea1feb4c250404acbe0d26fa0f883066f3bc27e8da292ff8e1f8770619d1a8f4ed1e1f52df41c930348c2a5a9c9602
data/ChangeLog CHANGED
@@ -1,5 +1,13 @@
1
1
  CHANGELOG
2
2
 
3
+ 2014-07-10 1.10.6
4
+
5
+ * Pass the configuration hash to the underlying ```Algolia.init``` method.
6
+
7
+ 2014-07-09 1.10.5
8
+
9
+ * Safely reindex your data using ```MyModel.reindex``` (index with a temporary index + move), ```MyModel.reindex!``` do it in-place without removing out-dated records
10
+
3
11
  2014-06-28 1.10.4
4
12
 
5
13
  * Ability to disable all indexing tasks (testing purpose)
data/README.md CHANGED
@@ -236,6 +236,8 @@ class Post < ActiveRecord::Base
236
236
  end
237
237
  ```
238
238
 
239
+ **Notes:** As soon as you use those constraints, ```deleteObjects``` calls will be performed in order to keep the index synced with the DB (The state-less gem doesn't know if the object don't match your constraints anymore or never matched, so we force DELETE operations, even on never-indexed objects).
240
+
239
241
  You can index a subset of your records using either:
240
242
 
241
243
  ```ruby
@@ -332,7 +334,13 @@ c.remove_from_index!
332
334
  c.destroy
333
335
  ```
334
336
 
335
- To reindex all your records, use the <code>reindex!</code> class method:
337
+ 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
+
339
+ ```ruby
340
+ Contact.reindex
341
+ ```
342
+
343
+ To reindex all your records (in place, without deleting out-dated records), use the <code>reindex!</code> class method:
336
344
 
337
345
  ```ruby
338
346
  Contact.reindex!
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.10.4
1
+ 1.10.6
@@ -6,11 +6,11 @@
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "algoliasearch-rails"
9
- s.version = "1.10.4"
9
+ s.version = "1.10.6"
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-06-28"
13
+ s.date = "2014-07-10"
14
14
  s.description = "AlgoliaSearch integration to your favorite ORM"
15
15
  s.email = "contact@algolia.com"
16
16
  s.extra_rdoc_files = [
@@ -154,6 +154,7 @@ module AlgoliaSearch
154
154
  class <<base
155
155
  alias_method :without_auto_index, :algolia_without_auto_index unless method_defined? :without_auto_index
156
156
  alias_method :reindex!, :algolia_reindex! unless method_defined? :reindex!
157
+ alias_method :reindex, :algolia_reindex unless method_defined? :reindex
157
158
  alias_method :index_objects, :algolia_index_objects unless method_defined? :index_objects
158
159
  alias_method :index!, :algolia_index! unless method_defined? :index!
159
160
  alias_method :remove_from_index!, :algolia_remove_from_index! unless method_defined? :remove_from_index!
@@ -221,6 +222,33 @@ module AlgoliaSearch
221
222
  nil
222
223
  end
223
224
 
225
+ # reindex whole database using a extra temporary index + move operation
226
+ def algolia_reindex(batch_size = 1000, synchronous = false)
227
+ return if @algolia_without_auto_index_scope
228
+ algolia_configurations.each do |options, settings|
229
+ next if algolia_indexing_disabled?(options)
230
+ next if options[:slave]
231
+ index_name = algolia_index_name(options)
232
+
233
+ tmp_options = options.merge({ :index_name => "#{index_name}.tmp" })
234
+ tmp_settings = settings.dup
235
+ tmp_index = algolia_ensure_init(tmp_options, tmp_settings)
236
+
237
+ algolia_find_in_batches(batch_size) do |group|
238
+ if algolia_conditional_index?(tmp_options)
239
+ # select only indexable objects
240
+ group = group.select { |o| algolia_indexable?(o, tmp_options) }
241
+ end
242
+ objects = group.map { |o| tmp_settings.get_attributes(o).merge 'objectID' => algolia_object_id_of(o, tmp_options) }
243
+ tmp_index.save_objects(objects)
244
+ end
245
+
246
+ move_task = ::Algolia.move_index(tmp_index.name, index_name)
247
+ tmp_index.wait_task(move_task["taskID"]) if synchronous == true
248
+ end
249
+ nil
250
+ end
251
+
224
252
  def algolia_index_objects(objects, synchronous = false)
225
253
  algolia_configurations.each do |options, settings|
226
254
  next if algolia_indexing_disabled?(options)
@@ -6,7 +6,7 @@ module AlgoliaSearch
6
6
 
7
7
  def configuration=(configuration)
8
8
  @@configuration = configuration
9
- Algolia.init :application_id => @@configuration[:application_id], :api_key => @@configuration[:api_key], :hosts => @@configuration[:hosts]
9
+ Algolia.init @@configuration
10
10
  end
11
11
  end
12
12
  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.10.4
4
+ version: 1.10.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Algolia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-28 00:00:00.000000000 Z
11
+ date: 2014-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json