How is Search Terms report produced?

I am looking to put together a SQL query to show me top search items for any given date range along with the CTR. Does anyone know how is the Search Logs report produced (it’s in …/admin/logs/search_logs?period=weekly) and especially how is the CTR calculated?

I see that there is a search_logs table, but not sure what is being looked at for CTR.

Thanks,
Oleg.

What an old topic without an answer, let’s bump it :smiley:

I would like to find out which topics were clicked for particular search term. I found this query, which comes close, but the tables seem to be deprecated since then:

Is there any way to achieve it on the latest version?

:wave:

https://github.com/discourse/discourse/blob/master/app/models/reports/trending_search.rb

and

https://github.com/discourse/discourse/blob/master/app/models/search_log.rb#L121

Should give you all you need to know.

4 Likes