A platform for community discussion. Free, open, simple.
FIX: Use same weights for calculating rank and searching for posts.
Guo Xiang Tan54d3648c55b9
diff --git a/lib/search.rb b/lib/search.rbindex a78937e87e8..33ae811ff18 100644--- a/lib/search.rb+++ b/lib/search.rb@@ -836,12 +836,18 @@ class Searchposts = posts.order("posts.like_count DESC")endelse- data_ranking = "TS_RANK_CD(post_search_data.search_data, #{ts_query})"+ data_ranking = <<~SQL+ TS_RANK_CD(+ post_search_data.search_data, #{ts_query(weight_filter: weights)}+ )+ SQL+if opts[:aggregate_search]posts = posts.order("MAX(#{data_ranking}) DESC")elseposts = posts.order("#{data_ranking} DESC")end+posts = posts.order("topics.bumped_at DESC")end