diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index cad216f4d..ce8b4a636 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -924,7 +924,7 @@ def list_indices # delete and create inactive index to use current mappings # Needs to run every time we change the mappings def upgrade_index(options = {}) - inactive_index ||= (options[:index] || inactive_index) + inactive_index ||= (options[:index] || self.inactive_index) __elasticsearch__.create_index!(index: inactive_index, force: true) "Upgraded inactive index #{inactive_index}." diff --git a/lib/tasks/client_prefix.rake b/lib/tasks/client_prefix.rake index d420a7573..12b148499 100644 --- a/lib/tasks/client_prefix.rake +++ b/lib/tasks/client_prefix.rake @@ -31,6 +31,11 @@ namespace :client_prefix do puts ClientPrefix.active_index + " is the active index." end + desc "Return inactive index for client_prefixes" + task inactive_index: :environment do + puts ClientPrefix.inactive_index + " is the inactive index." + end + desc "Monitor reindexing for client_prefixes" task monitor_reindex: :environment do puts ClientPrefix.monitor_reindex @@ -41,6 +46,21 @@ namespace :client_prefix do ClientPrefix.import(index: ENV["INDEX"] || ClientPrefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i) end + desc "Create alias for client_prefixes" + task create_alias: :environment do + puts ClientPrefix.create_alias(index: ENV["INDEX"], alias: ENV["ALIAS"]) + end + + desc "List aliases for client_prefixes" + task list_aliases: :environment do + puts ClientPrefix.list_aliases + end + + desc "Delete alias for client_prefixes" + task delete_alias: :environment do + puts ClientPrefix.delete_alias(index: ENV["INDEX"], alias: ENV["ALIAS"]) + end + desc "Delete from index by query" task delete_by_query: :environment do if ENV["QUERY"].nil? diff --git a/lib/tasks/prefix.rake b/lib/tasks/prefix.rake index 3052f834b..4490de8f0 100644 --- a/lib/tasks/prefix.rake +++ b/lib/tasks/prefix.rake @@ -31,6 +31,11 @@ namespace :prefix do puts Prefix.active_index + " is the active index." end + desc "Return inactive index for prefixes" + task inactive_index: :environment do + puts Prefix.inactive_index + " is the inactive index." + end + desc "Monitor reindexing for prefixes" task monitor_reindex: :environment do puts Prefix.monitor_reindex @@ -41,6 +46,21 @@ namespace :prefix do Prefix.import(index: ENV["INDEX"] || Prefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i) end + desc "Create alias for prefixes" + task create_alias: :environment do + puts Prefix.create_alias(index: ENV["INDEX"], alias: ENV["ALIAS"]) + end + + desc "List aliases for prefixes" + task list_aliases: :environment do + puts Prefix.list_aliases + end + + desc "Delete alias for prefixes" + task delete_alias: :environment do + puts Prefix.delete_alias(index: ENV["INDEX"], alias: ENV["ALIAS"]) + end + desc "Delete from index by query" task delete_by_query: :environment do if ENV["QUERY"].nil? diff --git a/lib/tasks/provider_prefix.rake b/lib/tasks/provider_prefix.rake index fdc380625..201a2bcec 100644 --- a/lib/tasks/provider_prefix.rake +++ b/lib/tasks/provider_prefix.rake @@ -31,6 +31,11 @@ namespace :provider_prefix do puts ProviderPrefix.active_index + " is the active index." end + desc "Return inactive index for provider_prefixes" + task inactive_index: :environment do + puts ProviderPrefix.inactive_index + " is the inactive index." + end + desc "Monitor reindexing for provider_prefixes" task monitor_reindex: :environment do puts ProviderPrefix.monitor_reindex @@ -41,6 +46,21 @@ namespace :provider_prefix do ProviderPrefix.import(index: ENV["INDEX"] || ProviderPrefix.inactive_index, batch_size: (ENV["BATCH_SIZE"] || 100).to_i) end + desc "Create alias for provider_prefixes" + task create_alias: :environment do + puts ProviderPrefix.create_alias(index: ENV["INDEX"], alias: ENV["ALIAS"]) + end + + desc "List aliases for provider_prefixes" + task list_aliases: :environment do + puts ProviderPrefixefix.list_aliases + end + + desc "Delete alias for provider_prefixes" + task delete_alias: :environment do + puts ProviderPrefix.delete_alias(index: ENV["INDEX"], alias: ENV["ALIAS"]) + end + desc "Delete from index by query" task delete_by_query: :environment do if ENV["QUERY"].nil?