-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CV2-6038 refactor has claim search filter into has article filter (#2205
) * CV2-6038: include explainer_title to has_article filter * CV2-6038: set value with nil instead of remove field from ES doc * CV2-6038: fix tests * CV2-6038: search by explainer_title field * CV2-6038: add rake task to migrate exisintg explainers * CV2-6038: use a single query for explainer titles * CV2-6038: apply PR comments
- Loading branch information
Showing
13 changed files
with
151 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
db/migrate/20250205224319_add_mapping_for_explainer_title_field.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
class AddMappingForExplainerTitleField < ActiveRecord::Migration[6.1] | ||
def change | ||
options = { | ||
index: CheckElasticSearchModel.get_index_alias, | ||
body: { | ||
properties: { | ||
explainer_title: { type: 'text', analyzer: 'check' }, | ||
} | ||
} | ||
} | ||
$repository.client.indices.put_mapping options | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
lib/tasks/migrate/20250205224319_add_mapping_for_explainer_title_field.rake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace :check do | ||
namespace :migrate do | ||
task project_media_explainer_title: :environment do | ||
started = Time.now.to_i | ||
index_alias = CheckElasticSearchModel.get_index_alias | ||
skip_pmids = [] | ||
es_body = [] | ||
ExplainerItem.find_each do |raw| | ||
next if skip_pmids.include?(raw.project_media_id) | ||
pm = raw.project_media | ||
doc_id = Base64.encode64("ProjectMedia/#{pm.id}") | ||
fields = { 'explainer_title' => pm.explainers_titles } | ||
es_body << { update: { _index: index_alias, _id: doc_id, retry_on_conflict: 3, data: { doc: fields } } } | ||
skip_pmids << pm.id | ||
end | ||
$repository.client.bulk body: es_body unless es_body.blank? | ||
minutes = ((Time.now.to_i - started) / 60).to_i | ||
puts "[#{Time.now}] Done in #{minutes} minutes." | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.