# 搜索词报告是如何生成的？

**URL:** https://meta.discourse.org/t/how-is-search-terms-report-produced/128727
**Category:** Data & reporting
**Tags:** dashboard-reports
**Created:** [2019年九月16日 20:44 UTC](https://meta.discourse.org/t/how-is-search-terms-report-produced/128727 "2019-09-16T20:44:03Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![olegbc1](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/olegbc1/32/154008_2.png) [@olegbc1](https://meta.discourse.org/u/olegbc1)
#### Post date: [2019年九月16日 20:44 UTC](https://meta.discourse.org/t/how-is-search-terms-report-produced/128727/1 "2019-09-16T20:44:03Z")

</div>

我想编写一个 SQL 查询，以显示任意给定日期范围内的热门搜索项及其点击率（CTR）。是否有人了解搜索日志报告（位于 …/admin/logs/search\_logs?period=weekly）是如何生成的，特别是 CTR 是如何计算的？

我看到有一个 search\_logs 表，但不确定 CTR 是基于哪些数据计算的。

谢谢，  
Oleg。

---

<div class="post-metadata">

### Author: ![loginerror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/loginerror/32/156605_2.png) [@loginerror](https://meta.discourse.org/u/loginerror)
#### Post date: [2019年十月23日 11:38 UTC](https://meta.discourse.org/t/how-is-search-terms-report-produced/128727/2 "2019-10-23T11:38:10Z")

</div>

多么古老且无解的话题啊，我来顶一下 😃

我想了解针对特定搜索词，哪些主题被点击过。我找到了这个查询，它接近目标，但相关表似乎已被弃用：

> [@Search usability and data](https://meta.discourse.org/t/search-usability-and-data/33149/19?u=maciej_kuzmicz):
>
> We actually did complete the work of logging the information. You can try out: SELECT term, count(\*) searches, sum(case when clicked\_topic\_id is not null then 1 else 0 end) "continued from search" from search\_logs where created\_at \> current\_timestamp - interval '30' day group by term order by count(\*) desc limit 100 It Data Explorer, it will show you top 100 searches and even counts of who actually clicked through from search. I find the results super interesting. We will work on exposin…

在最新版本中是否有任何方法可以实现这一功能？

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2019年十月23日 15:14 UTC](https://meta.discourse.org/t/how-is-search-terms-report-produced/128727/3 "2019-10-23T15:14:33Z")

</div>

👋

[https://github.com/discourse/discourse/blob/master/app/models/reports/trending\_search.rb](https://github.com/discourse/discourse/blob/master/app/models/reports/trending_search.rb)

以及

> <https://github.com/discourse/discourse/blob/main/app/models/search_log.rb#L121>

应该能为你提供所需的全部信息。

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [2023年七月4日 14:59 UTC](https://meta.discourse.org/t/how-is-search-terms-report-produced/128727/4 "2023-07-04T14:59:45Z")

</div>



---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [2023年七月4日 15:02 UTC](https://meta.discourse.org/t/how-is-search-terms-report-produced/128727/5 "2023-07-04T15:02:34Z")

</div>


