-
Notifications
You must be signed in to change notification settings - Fork 70
/
Rakefile
25 lines (20 loc) · 852 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
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application"
Rails.application.load_tasks
namespace :elasticsearch do
desc "Remove all exists indexes in ElasticSearch"
task clear: :environment do
puts "Remove elasticsearch..."
%w[Doc Repository Group User].each do |model_name|
model_name.constantize
end
puts Elasticsearch::Model::Registry.all.collect(&:index_name).join(", ").indent(4)
Elasticsearch::Model::Registry.all.each do |klass|
puts "Remove index: #{klass.index_name}".indent(4)
Elasticsearch::Model.client.indices.delete index: klass.index_name
rescue Elasticsearch::Transport::Transport::Errors::NotFound
end
end
end