# Zero search results searching private messages for specific keyword

**URL:** <https://meta.discourse.org/t/zero-search-results-searching-private-messages-for-specific-keyword/48429>\
**Category:** Bug\
**Created:** [Agosto 10, 2016, 3:24am UTC](https://meta.discourse.org/t/zero-search-results-searching-private-messages-for-specific-keyword/48429 "2016-08-10T03:24:41Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![DeanMarkTaylor](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/deanmarktaylor/32/102462_2.png) [@DeanMarkTaylor](https://meta.discourse.org/u/DeanMarkTaylor)\
**Post date:** [Agosto 10, 2016, 6:45pm UTC](https://meta.discourse.org/t/zero-search-results-searching-private-messages-for-specific-keyword/48429/5 "2016-08-10T18:45:25Z")

</div>

The actual query for “natwest” shown in mini profiler is as follows:

```SQL
SELECT "posts".* FROM "posts" JOIN (SELECT *, row_number() over() row_number FROM (SELECT topics.id, min(post_number) post_number FROM "posts" INNER JOIN "post_search_data" ON "post_search_data"."post_id" = "posts"."id" INNER JOIN "topics" ON "topics"."id" = "posts"."topic_id" AND ("topics"."deleted_at" IS NULL) LEFT JOIN categories ON categories.id = topics.category_id WHERE ("posts"."deleted_at" IS NULL) AND "posts"."post_type" IN (1, 2, 3, 4) AND "topics"."deleted_at" IS NULL AND (topics.visible) AND (topics.archetype = 'private_message') AND (post_search_data.search_data @@ TO_TSQUERY('english', '''natwest'':*')) AND (topics.id IN (SELECT topic_id
                                               FROM topic_allowed_users
                                               WHERE user_id = 1
                                               UNION ALL
                                               SELECT tg.topic_id
                                               FROM topic_allowed_groups tg
                                               JOIN group_users gu ON gu.user_id = 1 AND
                                                                        gu.group_id = tg.group_id)) AND ((categories.id IS NULL) OR (NOT categories.read_restricted) OR (categories.id IN (2,4,35,38,40,42,46,47,48,49,52,56,57,58,59,60,61,62,63,64,65,66,67,68,72,73,75,79,80,81,82,83,84,85,86,87,89,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,113,114,115,116,118,119))) GROUP BY topics.id ORDER BY TS_RANK_CD(TO_TSVECTOR('english', topics.title), TO_TSQUERY('english', '''natwest'':*')) DESC, SUM(TS_RANK_CD(post_search_data.search_data, TO_TSQUERY('english', '''natwest'':*'))) DESC, topics.bumped_at DESC LIMIT 50) xxx) x ON x.id = posts.topic_id AND x.post_number = posts.post_number WHERE ("posts"."deleted_at" IS NULL) ORDER BY row_number   

```

Completing a side-by-side comparison the only differences between “car” and “natwest” queries only that keyword changes.

Editing the query further removing the `ORDER BY` statement (confirming it still returns no results)…

… and then removing `AND (post_search_data.search_data @@ TO_TSQUERY('english', '''natwest'':*'))` then returns results.

A general search of public content (i.e. not limiting via `in:private`) for “natwest” returns results.

Is this helpful to you?

---

_[View the full topic](https://meta.discourse.org/t/zero-search-results-searching-private-messages-for-specific-keyword/48429)._
