From e8a4d72281599a0961da8147c9b3fdd4dad04a36 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Wed, 3 Apr 2019 14:05:50 +0800 Subject: [PATCH] FIX: Avoid penalizing long documents too much in search. This is a follow up to e87ca594014733d171df0112149f49180d898678. --- lib/search.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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