2014-02-03 12:08:41 +00:00
|
|
|
$LOAD_PATH << './lib'
|
|
|
|
require 'rubygems'
|
|
|
|
|
|
|
|
namespace :searchindex do
|
|
|
|
task :drop, [:opts] => :environment do |t, args|
|
|
|
|
|
|
|
|
# drop indexes
|
2015-04-27 13:20:16 +00:00
|
|
|
puts 'drop indexes...'
|
2014-02-03 12:08:41 +00:00
|
|
|
SearchIndexBackend.index(
|
2015-04-27 13:42:53 +00:00
|
|
|
action: 'delete',
|
2014-02-03 12:08:41 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
task :create, [:opts] => :environment do |t, args|
|
|
|
|
|
|
|
|
# create indexes
|
2015-04-27 13:20:16 +00:00
|
|
|
puts 'create indexes...'
|
2014-02-03 12:08:41 +00:00
|
|
|
SearchIndexBackend.index(
|
2015-04-27 13:42:53 +00:00
|
|
|
action: 'create',
|
|
|
|
data: {
|
|
|
|
mappings: {
|
|
|
|
Ticket: {
|
|
|
|
_source: { excludes: [ 'articles.attachments' ] },
|
|
|
|
properties: {
|
|
|
|
articles: {
|
|
|
|
type: 'nested',
|
|
|
|
properties: {
|
|
|
|
attachments: {
|
|
|
|
type: 'attachment',
|
2014-02-03 12:08:41 +00:00
|
|
|
}
|
2014-04-28 15:30:06 +00:00
|
|
|
}
|
2014-02-03 12:08:41 +00:00
|
|
|
}
|
2014-04-28 15:30:06 +00:00
|
|
|
}
|
|
|
|
}
|
2014-02-03 12:08:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
task :reload, [:opts] => :environment do |t, args|
|
|
|
|
|
2015-04-27 13:20:16 +00:00
|
|
|
puts 'reload data...'
|
2014-02-03 12:08:41 +00:00
|
|
|
User.search_index_reload
|
|
|
|
Organization.search_index_reload
|
|
|
|
Ticket.search_index_reload
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
task :rebuild, [:opts] => :environment do |t, args|
|
|
|
|
|
2015-04-27 13:20:16 +00:00
|
|
|
Rake::Task['searchindex:drop'].execute
|
|
|
|
Rake::Task['searchindex:create'].execute
|
|
|
|
Rake::Task['searchindex:reload'].execute
|
2014-02-03 12:08:41 +00:00
|
|
|
|
|
|
|
end
|
|
|
|
end
|