FIX: reindex_search job should work on model with no search data (#11819)

Lots of changes but it's mostly a refactoring.

The interesting part that was fix are the 'load_problem_<model>_ids' methods.
They will now return records with no search data associated so they can be properly indexed for the search.
This "bad" state usually happens after a migration.
This commit is contained in:
Régis Hanol
2021-01-25 11:23:36 +01:00
committed by GitHub
parent fcbb6c4143
commit aa1138ff71
6 changed files with 204 additions and 268 deletions

View File

@ -961,7 +961,7 @@ describe Search do
it 'can find posts with tags' do
# we got to make this index (it is deferred)
Jobs::ReindexSearch.new.rebuild_problem_posts
Jobs::ReindexSearch.new.rebuild_posts
result = Search.execute(tag.name)
expect(result.posts.length).to eq(1)
@ -977,7 +977,7 @@ describe Search do
it 'can find posts with tag synonyms' do
synonym = Fabricate(:tag, name: 'synonym', target_tag: tag)
Jobs::ReindexSearch.new.rebuild_problem_posts
Jobs::ReindexSearch.new.rebuild_posts
result = Search.execute(synonym.name)
expect(result.posts.length).to eq(1)
end