mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 23:58:31 -05:00
Also use the body of the post when looking for similar topics
This commit is contained in:
parent
0d238db43c
commit
b909e26fa4
1 changed files with 2 additions and 1 deletions
|
@ -319,11 +319,12 @@ class Topic < ActiveRecord::Base
|
||||||
return [] unless raw.present?
|
return [] unless raw.present?
|
||||||
|
|
||||||
# For now, we only match on title. We'll probably add body later on, hence the API hook
|
# For now, we only match on title. We'll probably add body later on, hence the API hook
|
||||||
similar = Topic.select(sanitize_sql_array(["topics.*, similarity(topics.title, :title) AS similarity", title: title]))
|
similar = Topic.select(sanitize_sql_array(["topics.*, similarity(topics.title, :title) + similarity(p.raw, :raw) AS similarity", title: title, raw: raw]))
|
||||||
.visible
|
.visible
|
||||||
.where(closed: false, archived: false)
|
.where(closed: false, archived: false)
|
||||||
.secured(Guardian.new(user))
|
.secured(Guardian.new(user))
|
||||||
.listable_topics
|
.listable_topics
|
||||||
|
.joins("LEFT OUTER JOIN posts AS p ON p.topic_id = topics.id AND p.post_number = 1")
|
||||||
.limit(SiteSetting.max_similar_results)
|
.limit(SiteSetting.max_similar_results)
|
||||||
.order('similarity desc')
|
.order('similarity desc')
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue