2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-06 10:50:21 +08:00

FEATURE: show tags in search results

This commit is contained in:
Neil Lalonde 2017-08-25 11:52:18 -04:00
parent cdcc5d6174
commit 2c56f8df7c
14 changed files with 162 additions and 2 deletions

View file

@ -18,7 +18,7 @@ class Search
end
def self.facets
%w(topic category user private_messages)
%w(topic category user private_messages tags)
end
def self.ts_config(locale = SiteSetting.default_locale)
@ -553,6 +553,7 @@ class Search
unless @search_context
user_search if @term.present?
category_search if @term.present?
tags_search if @term.present?
end
topic_search
end
@ -631,6 +632,20 @@ class Search
end
end
def tags_search
return unless SiteSetting.tagging_enabled
tags = Tag.includes(:tag_search_data)
.where("tag_search_data.search_data @@ #{ts_query}")
.references(:tag_search_data)
.order("name asc")
.limit(limit)
tags.each do |tag|
@results.add(tag)
end
end
def posts_query(limit, opts = nil)
opts ||= {}
posts = Post.where(post_type: Topic.visible_post_types(@guardian.user))

View file

@ -14,6 +14,7 @@ class Search
:posts,
:categories,
:users,
:tags,
:more_posts,
:more_categories,
:more_users,
@ -34,6 +35,7 @@ class Search
@posts = []
@categories = []
@users = []
@tags = []
end
def find_user_data(guardian)