This repository has been archived by the owner on Mar 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add rake tasks to build Redis indexes.
- Loading branch information
Showing
8 changed files
with
51 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require "redis_search" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module RedisSearch | ||
class Railtie < Rails::Railtie | ||
rake_tasks do | ||
load File.expand_path('../tasks.rb', __FILE__) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding: utf-8 | ||
namespace :redis_search do | ||
desc "RedisSearch index data to Redis" | ||
task :index => :environment do | ||
tm = Time.now | ||
count = 0 | ||
puts "redis-search index".upcase.rjust(120) | ||
puts "-"*120 | ||
puts "Now indexing search to Redis...".rjust(120) | ||
puts "" | ||
RedisSearch::Search.indexed_models.each do |klass| | ||
print "[#{klass.to_s}]" | ||
klass.find_in_batches(:batch_size => 1000) do |items| | ||
items.each do |item| | ||
item.redis_search_index_create | ||
item = nil | ||
count += 1 | ||
print "." | ||
end | ||
end | ||
puts "" | ||
end | ||
puts "" | ||
puts "-"*120 | ||
puts "Indexed #{count} rows | Time spend: #{(Time.now - tm)}s".rjust(120) | ||
puts "Rebuild Index done.".rjust(120) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters