FEATURE: search within title using in:title

Also

- Significantly improved search ranking, title is treated most strongly
- Adds tag names to the index
- Run search re-indexer more aggressively
- Re-index topic and all posts on category change
This commit is contained in:
Sam
2018-02-20 14:41:00 +11:00
parent 73a492f721
commit 86d12bd44b
8 changed files with 187 additions and 110 deletions

View File

@@ -223,10 +223,15 @@ class Topic < ActiveRecord::Base
ApplicationController.banner_json_cache.clear
end
if tags_changed
TagUser.auto_watch(topic_id: id)
TagUser.auto_track(topic_id: id)
self.tags_changed = false
if tags_changed || saved_change_to_attribute?(:category_id)
SearchIndexer.queue_post_reindex(self.id)
if tags_changed
TagUser.auto_watch(topic_id: id)
TagUser.auto_track(topic_id: id)
self.tags_changed = false
end
end
SearchIndexer.index(self)
@@ -474,7 +479,7 @@ class Topic < ActiveRecord::Base
search_data = "#{title} #{raw[0...MAX_SIMILAR_BODY_LENGTH]}".strip
filter_words = Search.prepare_data(search_data)
ts_query = Search.ts_query(filter_words, nil, "|")
ts_query = Search.ts_query(term: filter_words, joiner: "|")
candidates = Topic
.visible