Skip to content

Commit

Permalink
Improvements to Rake tasks
Browse files Browse the repository at this point in the history
* Rescue timeouts when trying to create existing index
* Correct handling of index to keep when deleting indices
  • Loading branch information
karmi committed May 30, 2012
1 parent 2194f02 commit 0316596
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,24 @@ namespace :index do
task :create do
1.upto(COUNT) do |i|
print "#{i}. "
Tire.index("index_#{i}") do
create
store title: "Test doc"
end
Timeout::timeout(0.25) do
Tire.index("index_#{i}") do
create settings: { number_of_shards: 3, number_of_replicas: 1 }
store title: "Test doc"
end
end rescue Timeout::Error
end
end

desc "Remove indices (pass LEAVE in ENV)"
task :remove do
COUNT.downto(LEAVE) do |i|
COUNT.downto(LEAVE+1) do |i|
print "#{i}. "
Tire.index("index_#{i}").delete
end
end

desc "Search an index in loop"
desc "Search an index in a loop"
task :search do
trap(:INT) { exit }
INDEX = ENV['INDEX'] || 'index_1'
Expand Down

0 comments on commit 0316596

Please sign in to comment.