algoliasearch-rails 1.3.4 → 1.3.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/README.md +10 -0
- data/VERSION +1 -1
- data/algoliasearch-rails.gemspec +1 -1
- data/lib/algoliasearch-rails.rb +12 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d725221ebe1951d7402c2ebd39d0d3a5f842d492
|
4
|
+
data.tar.gz: 7bd0b0ffbf077922c58435ae10723b098bda4eba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37fe184cd8ee01faa96adcdbcc3d1fe8665d03ec5957798828ebf04753f2e9e42a8118f2b52597eaedef67114a432134f61df0aafd697062f53d9edf17b1987f
|
7
|
+
data.tar.gz: d51d0d58a0e07e3920a7ee280525036ed77548432e7793ad85cc6f39f4504cb72b770eec2e08541e4bb4e91f827413584b7131e339c50aa49c213c56558d2e54
|
data/ChangeLog
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
|
+
2013-11-07 1.3.5
|
4
|
+
|
5
|
+
* add without_auto_index_scope method disabling all indexing operations inside associated block
|
6
|
+
|
3
7
|
2013-11-07 1.3.4
|
4
8
|
|
5
9
|
* updated algoliasearch to 1.1.6 (clear_index! is now a real clear, not a delete/create) and algoliasearch-client-js to 2.3.0
|
data/README.md
CHANGED
@@ -103,6 +103,16 @@ class Contact < ActiveRecord::Base
|
|
103
103
|
end
|
104
104
|
```
|
105
105
|
|
106
|
+
You can temporary disable auto-indexing using the <code>without_auto_index</code> scope. This is often used for performance reason.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
Contact.delete_all
|
110
|
+
Contact.without_auto_index do
|
111
|
+
1.upto(10000) { Contact.create! attributes } # inside the block, auto indexing task will noop
|
112
|
+
end
|
113
|
+
Contact.reindex! # will use batch operations
|
114
|
+
```
|
115
|
+
|
106
116
|
You can force indexing and removing to be synchronous by setting the following option:
|
107
117
|
|
108
118
|
```ruby
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.5
|
data/algoliasearch-rails.gemspec
CHANGED
data/lib/algoliasearch-rails.rb
CHANGED
@@ -103,7 +103,17 @@ module AlgoliaSearch
|
|
103
103
|
@options = { type: model_name, per_page: @index_options.get(:hitsPerPage) || 10, page: 1 }.merge(options)
|
104
104
|
end
|
105
105
|
|
106
|
+
def without_auto_index(&block)
|
107
|
+
@without_auto_index_scope = true
|
108
|
+
begin
|
109
|
+
yield
|
110
|
+
ensure
|
111
|
+
@without_auto_index_scope = false
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
106
115
|
def reindex!(batch_size = 1000, synchronous = false)
|
116
|
+
return if @without_auto_index_scope
|
107
117
|
ensure_init
|
108
118
|
last_task = nil
|
109
119
|
find_in_batches(batch_size: batch_size) do |group|
|
@@ -114,6 +124,7 @@ module AlgoliaSearch
|
|
114
124
|
end
|
115
125
|
|
116
126
|
def index!(object, synchronous = false)
|
127
|
+
return if @without_auto_index_scope
|
117
128
|
ensure_init
|
118
129
|
if synchronous
|
119
130
|
@index.add_object!(attributes(object), object.id.to_s)
|
@@ -123,6 +134,7 @@ module AlgoliaSearch
|
|
123
134
|
end
|
124
135
|
|
125
136
|
def remove_from_index!(object, synchronous = false)
|
137
|
+
return if @without_auto_index_scope
|
126
138
|
ensure_init
|
127
139
|
if synchronous
|
128
140
|
@index.delete_object!(object.id.to_s)
|