Skip to content

A platform for community discussion. Free, open, simple.

FIX: Avoid penalizing long documents too much in search.

Guo Xiang Tane8a4d7228159
diff --git a/lib/search.rb b/lib/search.rb
index 61b4c251e7f..fbc1e8c12ed 100644
--- a/lib/search.rb
+++ b/lib/search.rb
@@ -836,14 +836,14 @@ class Search
posts = posts.order("posts.like_count DESC")
end
else
- # 2|32 divides the rank by the document length and scales the range from
- # zero to one
+ # 1|32 divides the rank by 1 + logarithm of the document length and
+ # scales the range from zero to one
data_ranking = <<~SQL
(
TS_RANK_CD(
post_search_data.search_data,
#{ts_query(weight_filter: weights)},
- 2|32
+ 1|32
) *
(
CASE categories.search_priority