-
Notifications
You must be signed in to change notification settings - Fork 63
/
Rakefile
43 lines (36 loc) · 897 Bytes
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
STDOUT.sync = true
require 'rake'
require 'tire'
namespace :index do
COUNT = (ENV['COUNT'] || 10).to_i
LEAVE = (ENV['LEAVE'] || 2 ).to_i
desc "Create indices (pass COUNT in ENV)"
task :create do
1.upto(COUNT) do |i|
print "#{i}. "
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+1) do |i|
print "#{i}. "
Tire.index("index_#{i}").delete
end
end
desc "Search an index in a loop"
task :search do
trap(:INT) { exit }
INDEX = ENV['INDEX'] || 'index_1'
loop do
Tire.search(INDEX) { query { string 'tes*' } }.results
print '.'
sleep 0.2
end
end
end