mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-05-04 22:04:18 -04:00
adding a rake task to generate elasticsearch index
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user