redis-search 1.0.1 → 1.0.2
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/lib/redis-search/base.rb +5 -4
- data/lib/redis-search/tasks.rb +3 -3
- data/lib/redis-search/version.rb +1 -1
- 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: 804fc6a6a29426a456e61001196c3649286e0ec1
|
4
|
+
data.tar.gz: 580d8cea7d7bc1189bf3bf05ac701b4f1758de07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa20b21f334eb09449a3271a702a95f6c1f2f537eec92d7128046e887cfc6c995a35a27ae5a4c486045bda1b97f01650b656c2d8c02ce0faeeac6fcba5a0414e
|
7
|
+
data.tar.gz: 2ecdffdd2e841868404602a79d0445e98cf0e7e1ad6181417dd61c76b8a61bf0bce6c5e0ef568a5374d16e37b5328d6b1e1a622156572636f8ed035f01976c7c
|
data/lib/redis-search/base.rb
CHANGED
@@ -147,15 +147,17 @@ class Redis
|
|
147
147
|
Redis::Search.complete(self.name, q, opts)
|
148
148
|
end
|
149
149
|
|
150
|
-
def redis_search_index_batch_create(batch_size = 1000
|
150
|
+
def redis_search_index_batch_create(batch_size = 1000)
|
151
151
|
count = 0
|
152
152
|
if ancestors.collect(&:to_s).include?('ActiveRecord::Base'.freeze)
|
153
153
|
find_in_batches(batch_size: batch_size) do |items|
|
154
154
|
_redis_search_reindex_items(items)
|
155
|
+
count += item.count
|
155
156
|
end
|
156
157
|
elsif included_modules.collect(&:to_s).include?('Mongoid::Document'.freeze)
|
157
|
-
all.each_slice(batch_size) do |items|
|
158
|
+
self.all.each_slice(batch_size) do |items|
|
158
159
|
_redis_search_reindex_items(items)
|
160
|
+
count += item.count
|
159
161
|
end
|
160
162
|
else
|
161
163
|
puts 'skiped, not support this ORM in current.'
|
@@ -169,8 +171,7 @@ class Redis
|
|
169
171
|
def _redis_search_reindex_items(items)
|
170
172
|
items.each do |item|
|
171
173
|
item.redis_search_index_create
|
172
|
-
|
173
|
-
print DOT if progressbar
|
174
|
+
print DOT
|
174
175
|
item = nil
|
175
176
|
end
|
176
177
|
items = nil
|
data/lib/redis-search/tasks.rb
CHANGED
@@ -32,10 +32,10 @@ namespace :redis_search do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
klass = Object.const_get(ENV['CLASS'].to_s)
|
35
|
-
batch = ENV['BATCH'].to_i
|
35
|
+
batch = ENV['BATCH'].to_i > 0 ? ENV['BATCH'].to_i : 1000
|
36
36
|
start = Time.now
|
37
37
|
puts "Redis-Search index data to Redis from [#{klass}]"
|
38
|
-
count = klass.redis_search_index_batch_create(batch
|
38
|
+
count = klass.redis_search_index_batch_create(batch)
|
39
39
|
puts ''
|
40
40
|
puts "Indexed #{count} rows | Time spend: #{(Time.now - start)}s"
|
41
41
|
puts 'Rebuild Index done.'
|
@@ -63,7 +63,7 @@ namespace :redis_search do
|
|
63
63
|
puts "Redis-Search index data to Redis from [#{dir}]"
|
64
64
|
Redis::Search.indexed_models.each do |klass|
|
65
65
|
puts "[#{klass}]"
|
66
|
-
count += klass.redis_search_index_batch_create(batch
|
66
|
+
count += klass.redis_search_index_batch_create(batch)
|
67
67
|
puts ''
|
68
68
|
end
|
69
69
|
puts "Indexed #{count} rows | Time spend: #{(Time.now - tm)}s"
|
data/lib/redis-search/version.rb
CHANGED