0
desc "Index Elastic Search"
namespace :tire do
namespace :import do
task all: :environment do
aliases = Tire::Configuration.client.get(Tire::Configuration.url + '/_aliases').body
indexes_names = MultiJson.load(aliases).keys
indexes_names.each do |name|
index = Tire::Index.new name
index.delete
index.import
index.refresh
puts "[INFO] #{name} re-indexed"
end
end
end
end
但我得到一個錯誤
wrong number of arguments (0 for 1)
/Users/rege/.rvm/gems/[email protected]/gems/tire-0.5.2/lib/tire/index.rb:185:in `import'
/Users/rege/Code/Network/lib/tasks/tire.rake:15:in `block (4 levels) in <top (required)>'
/Users/rege/Code/Network/lib/tasks/tire.rake:12:in `each'
/Users/rege/Code/Network/lib/tasks/tire.rake:12:in `block (3 levels) in <top (required)>'
Tasks: TOP => tire:import:all
我每個索引的名字前有我的應用程序和環境的名稱:''myapp_development__links''所以你的解決方案給我:''未初始化的常量MyAppDevelopmentLink'' – tomekfranek
正如預期的那樣,請看我更新的答案。 –
我也加了''test''嗯,但我想知道是否正確的方法來做到這一點? – tomekfranek