A platform for community discussion. Free, open, simple.
DEV: Allow developmental post search index versions.
Guo Xiang Tan3766122a82af
diff --git a/app/jobs/scheduled/reindex_search.rb b/app/jobs/scheduled/reindex_search.rbindex 651a3325d0c..16da800f945 100644--- a/app/jobs/scheduled/reindex_search.rb+++ b/app/jobs/scheduled/reindex_search.rb@@ -140,7 +140,7 @@ module Jobsdef load_problem_post_ids(limit)params = {locale: SiteSetting.default_locale,- version: SearchIndexer::POST_INDEX_VERSION,+ version: SearchIndexer::MIN_POST_REINDEX_VERSION,limit: limit}@@ -151,7 +151,7 @@ module JobsJOIN topics ON topics.id = posts.topic_idLEFT JOIN post_search_data pdON pd.locale = :locale- AND pd.version = :version+ AND pd.version >= :versionAND pd.post_id = posts.idWHERE pd.post_id IS NULLAND posts.deleted_at IS NULLdiff --git a/app/services/search_indexer.rb b/app/services/search_indexer.rbindex cb68c0ce595..27a18f7dbb5 100644--- a/app/services/search_indexer.rb+++ b/app/services/search_indexer.rb@@ -2,6 +2,7 @@class SearchIndexerPOST_INDEX_VERSION = 3+ MIN_POST_REINDEX_VERSION = 3TOPIC_INDEX_VERSION = 3CATEGORY_INDEX_VERSION = 3USER_INDEX_VERSION = 3diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rbindex 339527e49ee..cd28cf08c35 100644--- a/spec/jobs/reindex_search_spec.rb+++ b/spec/jobs/reindex_search_spec.rb@@ -68,6 +68,14 @@ describe Jobs::ReindexSearch doexpect(FakeIndexer.posts).to contain_exactly(post)end+ it 'should not reindex posts with a developmental version' do+ post = Fabricate(:post, version: SearchIndexer::MIN_POST_REINDEX_VERSION + 1)++ subject.rebuild_problem_posts(indexer: FakeIndexer)++ expect(FakeIndexer.posts).to eq([])+ end+it 'should not reindex posts with empty raw' dopost = Fabricate(:post)post.post_search_data.destroy!