adding a rake task to generate elasticsearch index

This commit is contained in:
Shiho Takagi
2015-01-25 15:47:40 +11:00
parent 684a3d2229
commit 5a96b7efd6
2 changed files with 7 additions and 18 deletions

View File

@@ -314,6 +314,13 @@ namespace :growstuff do
end
end
end
desc "January 2015: build Elasticsearch index"
task :elasticsearch_create_index => :environment do
Crop.__elasticsearch__.create_index! force: true
Crop.import
end
end # end oneoff section
end

View File

@@ -1,18 +0,0 @@
module ElasticsearchHelpers
def sync_elasticsearch(crops)
if ENV['GROWSTUFF_ELASTICSEARCH'] == "true"
crops.each {|crop| crop.__elasticsearch__.index_document}
Crop.__elasticsearch__.refresh_index!
end
end
end
RSpec.configure do |config|
config.include ElasticsearchHelpers
config.before(:each) do
if ENV['GROWSTUFF_ELASTICSEARCH'] == "true"
Crop.__elasticsearch__.create_index! force: true
end
end
end