Search / Watching for Tags only populates Topics with the tag, not replies

We use Discourse as a knowledge & feedback sharing forum for our employees, partners, and customers. We’ve communicated to everyone that they should add a docrequest tag to a Topic or Post if a community conversation uncovers a topic for which we need to add or improve our documentation; our product team, in turn, has set their watching preferences to be notified any time the docrequest tag is used.

What we are finding is that the tag neither populates in the Search bar nor in tracking notifications if the tag is used in a reply post - it only ever works if it’s added to the original Topic. I, as the community moderator and admin, then need to monitor every post for the tag and then manually add the tag to the original topic. This obviously does not scale.

Am I doing something incorrectly or is there a setting I can change?

Hi Dan :slight_smile:

I have a bit of trouble understanding, as tags can only be added to topics, not posts.

@Canapin you can add a tag to a post body simply by typing # then begin typing the tag name…such as bug :slight_smile:

That is a link, not tagging.

1 Like

well, crap

You can reference a tag in a post, but only a topic can actually be tagged as such.

However, if you have the data explorer plugin you could use a query something like this to pull up a list of ones where the tag has been linked in a post:

-- [params]
-- string :hashtag
-- date :start_date
-- date :end_date 

WITH target_posts AS (
  SELECT 
    p.id AS post_id,
    t.category_id,
    p.created_at
  FROM posts p
  JOIN topics t ON p.topic_id = t.id
  JOIN users u ON u.id = p.user_id
  WHERE t.deleted_at IS NULL
    AND t.archetype = 'regular'
    AND p.deleted_at IS NULL
    AND p.post_type = 1
    AND p.created_at::date BETWEEN :start_date AND :end_date
    AND p.post_number <> 1
)

SELECT
  tp.category_id,
  tp.post_id,
  tp.created_at::date
FROM target_posts tp
LEFT JOIN post_search_data psd ON psd.post_id = tp.post_id
WHERE psd.search_data @@ TO_TSQUERY(:hashtag)
ORDER BY tp.created_at DESC

2 Likes

Thank you. Without an easy button, that will have to do. I’ve also gone in and added Watched Words to auto-create the tag if needed, but again, I think that only works for Topics. It would be great if there was a way to add tags to Posts - perhaps most folks would find that a bit much, but if it was a setting that could be toggled on, I know it would sure help at least our scenario. Anyway, thanks for the info, all!

2 Likes