mirror of
https://github.com/discourse/discourse.git
synced 2025-05-28 13:51:18 +08:00
FIX: Use same weights for calculating rank and searching for posts.
* Reduce an extra db query as well when searching for posts ordered by relevance.
This commit is contained in:
@ -836,12 +836,18 @@ class Search
|
|||||||
posts = posts.order("posts.like_count DESC")
|
posts = posts.order("posts.like_count DESC")
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
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]
|
if opts[:aggregate_search]
|
||||||
posts = posts.order("MAX(#{data_ranking}) DESC")
|
posts = posts.order("MAX(#{data_ranking}) DESC")
|
||||||
else
|
else
|
||||||
posts = posts.order("#{data_ranking} DESC")
|
posts = posts.order("#{data_ranking} DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
posts = posts.order("topics.bumped_at DESC")
|
posts = posts.order("topics.bumped_at DESC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user