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

**URL:** <https://meta.discourse.org/t/search-watching-for-tags-only-populates-topics-with-the-tag-not-replies/272299>\
**Category:** Feature\
**Tags:** tags\
**Created:** [July 20, 2023, 2:48pm UTC](https://meta.discourse.org/t/search-watching-for-tags-only-populates-topics-with-the-tag-not-replies/272299 "2023-07-20T14:48:57Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [July 20, 2023, 3:23pm UTC](https://meta.discourse.org/t/search-watching-for-tags-only-populates-topics-with-the-tag-not-replies/272299/6 "2023-07-20T15:23:14Z")

</div>

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](https://meta.discourse.org/t/32566?silent=true) 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:

```sql
-- [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

```

 ![example results](https://global.discourse-cdn.com/meta/original/4X/5/5/7/5570d06080a1706d641a59224dd592a194c46fc5.png)

---

_[View the full topic](https://meta.discourse.org/t/search-watching-for-tags-only-populates-topics-with-the-tag-not-replies/272299)._
