# 添加站点设置，将默认搜索结果按最新帖子而非相关性排序

**URL:** <https://meta.discourse.org/t/add-site-setting-to-default-search-results-sort-by-latest-post-instead-of-relevance/140294>\
**Category:** Feature\
**Tags:** search, completed\
**Created:** [2020 年1 月 31 日 11:47 UTC](https://meta.discourse.org/t/add-site-setting-to-default-search-results-sort-by-latest-post-instead-of-relevance/140294 "2020-01-31T11:47:53Z")\
**Posts on this page:** 1\
**Showing post:** 33

<div class="post-metadata">

作者： ![martin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/martin/32/491371_2.png) [@martin](https://meta.discourse.org/u/martin)\
发布日期： [2023 年11 月 20 日 00:45 UTC](https://meta.discourse.org/t/add-site-setting-to-default-search-results-sort-by-latest-post-instead-of-relevance/140294/33 "2023-11-20T00:45:07Z")

</div>

我刚刚合并了一个新功能：

> <https://github.com/discourse/discourse/pull/24428>
>
> This commit adds a new \`search\_default\_sort\_order\` site setting,
> set to "releva…nce" by default, that controls the default sort order
> for the full page /search route.
> 
> If the user changes the order in the dropdown on that page, we remember
> their preference automatically, and it takes precedence over the site
> setting as a default from then on. This way people who prefer e.g.
> Latest Post as their default can make it so.

这添加了一个新的 `search_default_sort_order` 站点设置，默认设置为“relevance”（相关性），它控制着 `/search` 全页路由的默认排序顺序。

如果用户在该页面更改下拉菜单中的顺序，我们会自动记住他们的偏好，并且此后它将优先于站点设置作为默认值。该偏好存储在浏览器的 LocalStorage 中，因此它是设备特定的。

---

_[View the full topic](https://meta.discourse.org/t/add-site-setting-to-default-search-results-sort-by-latest-post-instead-of-relevance/140294)._
