DEV: Add hidden site setting for PG search ranking normalization.

This commit is contained in:
Guo Xiang Tan 2020-07-02 14:11:18 +08:00
parent ecc799ab56
commit af52df2d96
No known key found for this signature in database
GPG Key ID: FBD110179AAC1F20
2 changed files with 4 additions and 3 deletions

View File

@ -1730,6 +1730,9 @@ backups:
hidden: true hidden: true
search: search:
search_ranking_normalization:
default: '1'
hidden: true
search_inject_extra_terms: search_inject_extra_terms:
default: true default: true
hidden: true hidden: true

View File

@ -937,14 +937,12 @@ class Search
posts = posts.order("posts.like_count DESC") posts = posts.order("posts.like_count DESC")
end end
else else
# 1|32 divides the rank by 1 + logarithm of the document length and
# scales the range from zero to one
data_ranking = <<~SQL data_ranking = <<~SQL
( (
TS_RANK_CD( TS_RANK_CD(
post_search_data.search_data, post_search_data.search_data,
#{ts_query(weight_filter: weights)}, #{ts_query(weight_filter: weights)},
1|32 #{Sitesetting.search_ranking_normalization}|32
) * ) *
( (
CASE categories.search_priority CASE categories.search_priority