Add --only-mapping option to tootctl search deploy (#34466)

This commit is contained in:
Eugen Rochko 2025-04-17 11:09:03 +02:00 committed by GitHub
parent ee62ac53e1
commit c01d219c12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ module Mastodon::CLI
option :import, type: :boolean, default: true, desc: 'Import data from the database to the index' option :import, type: :boolean, default: true, desc: 'Import data from the database to the index'
option :clean, type: :boolean, default: true, desc: 'Remove outdated documents from the index' option :clean, type: :boolean, default: true, desc: 'Remove outdated documents from the index'
option :reset_chewy, type: :boolean, default: false, desc: "Reset Chewy's internal index" option :reset_chewy, type: :boolean, default: false, desc: "Reset Chewy's internal index"
option :only_mapping, type: :boolean, default: false, desc: 'Update the index specification without re-index'
desc 'deploy', 'Create or upgrade Elasticsearch indices and populate them' desc 'deploy', 'Create or upgrade Elasticsearch indices and populate them'
long_desc <<~LONG_DESC long_desc <<~LONG_DESC
If Elasticsearch is empty, this command will create the necessary indices If Elasticsearch is empty, this command will create the necessary indices
@ -52,6 +53,20 @@ module Mastodon::CLI
Chewy::Stash::Specification.reset! if options[:reset_chewy] Chewy::Stash::Specification.reset! if options[:reset_chewy]
if options[:only_mapping]
indices.select { |index| index.specification.changed? }.each do |index|
progress.title = "Updating mapping for #{index} "
index.update_mapping
index.specification.lock!
end
progress.title = 'Done! '
progress.finish
say('Updated index mappings', :green, true)
return
end
# First, ensure all indices are created and have the correct # First, ensure all indices are created and have the correct
# structure, so that live data can already be written # structure, so that live data can already be written
indices.select { |index| index.specification.changed? }.each do |index| indices.select { |index| index.specification.changed? }.each do |index|