mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
FEATURE: apply a small penalty to closed topics when searching (#7782)
This commit is contained in:
@ -861,7 +861,11 @@ class Search
|
|||||||
THEN #{SiteSetting.category_search_priority_high_weight}
|
THEN #{SiteSetting.category_search_priority_high_weight}
|
||||||
WHEN #{Searchable::PRIORITIES[:very_high]}
|
WHEN #{Searchable::PRIORITIES[:very_high]}
|
||||||
THEN #{SiteSetting.category_search_priority_very_high_weight}
|
THEN #{SiteSetting.category_search_priority_very_high_weight}
|
||||||
ELSE 1
|
ELSE
|
||||||
|
CASE WHEN topics.closed
|
||||||
|
THEN 0.9
|
||||||
|
ELSE 1
|
||||||
|
END
|
||||||
END
|
END
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -359,6 +359,26 @@ describe Search do
|
|||||||
post.id, category.topic.first_post.id, post2.id
|
post.id, category.topic.first_post.id, post2.id
|
||||||
])
|
])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'applies a small penalty to closed topic when ranking' do
|
||||||
|
post = Fabricate(:post,
|
||||||
|
raw: "My weekly update",
|
||||||
|
topic: Fabricate(:topic,
|
||||||
|
title: "A topic that will be closed",
|
||||||
|
closed: true
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
post2 = Fabricate(:post,
|
||||||
|
raw: "My weekly update",
|
||||||
|
topic: Fabricate(:topic,
|
||||||
|
title: "A topic that will be open"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
result = Search.execute('weekly update')
|
||||||
|
expect(result.posts.pluck(:id)).to eq([post2.id, post.id])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'searching for quoted title' do
|
context 'searching for quoted title' do
|
||||||
|
Reference in New Issue
Block a user