Skip to content

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.rb
index 651a3325d0c..16da800f945 100644
--- a/app/jobs/scheduled/reindex_search.rb
+++ b/app/jobs/scheduled/reindex_search.rb
@@ -140,7 +140,7 @@ module Jobs
def 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 Jobs
JOIN topics ON topics.id = posts.topic_id
LEFT JOIN post_search_data pd
ON pd.locale = :locale
- AND pd.version = :version
+ AND pd.version >= :version
AND pd.post_id = posts.id
WHERE pd.post_id IS NULL
AND posts.deleted_at IS NULL
diff --git a/app/services/search_indexer.rb b/app/services/search_indexer.rb
index cb68c0ce595..27a18f7dbb5 100644
--- a/app/services/search_indexer.rb
+++ b/app/services/search_indexer.rb
@@ -2,6 +2,7 @@
class SearchIndexer
POST_INDEX_VERSION = 3
+ MIN_POST_REINDEX_VERSION = 3
TOPIC_INDEX_VERSION = 3
CATEGORY_INDEX_VERSION = 3
USER_INDEX_VERSION = 3
diff --git a/spec/jobs/reindex_search_spec.rb b/spec/jobs/reindex_search_spec.rb
index 339527e49ee..cd28cf08c35 100644
--- a/spec/jobs/reindex_search_spec.rb
+++ b/spec/jobs/reindex_search_spec.rb
@@ -68,6 +68,14 @@ describe Jobs::ReindexSearch do
expect(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' do
post = Fabricate(:post)
post.post_search_data.destroy!