diff --git a/app/models/attachment.rb b/app/models/attachment.rb index b8aa14cefff..05289c7ac89 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -189,10 +189,17 @@ class Attachment < ActiveRecord::Base # Extract the fulltext of any attachments where fulltext is still nil. # This runs inline and not in a asynchronous worker. - def self.extract_fulltext + def self.extract_fulltext_where_missing Attachment.where(fulltext: nil).pluck(:id).each do |id| job = ExtractFulltextJob.new(id) job.perform end end + + def self.force_extract_fulltext + Attachment.pluck(:id).each do |id| + job = ExtractFulltextJob.new(id) + job.perform + end + end end diff --git a/docs/operations/upgrading/manual/upgrading.md b/docs/operations/upgrading/manual/upgrading.md index c8f3a564036..8e8b92240d0 100644 --- a/docs/operations/upgrading/manual/upgrading.md +++ b/docs/operations/upgrading/manual/upgrading.md @@ -230,7 +230,7 @@ To make sure that all work package attachments are indexed, so that their conten run: ```bash -[openproject@debian]# RAILS_ENV="production" rake attachments:extract_fulltext +[openproject@debian]# RAILS_ENV="production" rake extract_fulltext_where_missing ``` diff --git a/lib/tasks/extract_fulltext.rake b/lib/tasks/extract_fulltext.rake index d2c10adc041..d06a94cc506 100644 --- a/lib/tasks/extract_fulltext.rake +++ b/lib/tasks/extract_fulltext.rake @@ -27,7 +27,12 @@ # See doc/COPYRIGHT.rdoc for more details. #++ -desc 'Makes existing attachments fulltext searchable' -task extract_fulltext: :environment do - Attachment.extract_fulltext +desc 'Extracts fulltext of attachments that were not extracted yet and provide it for attachment filter.' +task extract_fulltext_where_missing: :environment do + Attachment.extract_fulltext_where_missing +end + +desc 'Extracts fulltext of all attachments and provide it for attachment filter even if that attachment has been extracted before.' +task force_extract_fulltext: :environment do + Attachment.force_extract_fulltext end