Searching for content effectively

:bookmark: This guide provides a comprehensive overview of Discourse’s search capabilities, including filters, options, and advanced techniques.

:person_raising_hand: Required user level: All users

Discourse offers a powerful search functionality with numerous filters and criteria. When you use the advanced search form, it automatically appends the relevant syntax to your query. For example, selecting [x] In my messages will add in:personal to your search query.

This guide covers all available search options and features in Discourse, and provides useful tips and tricks for using the search function.

Filters

Discourse provides a wide range of filters to help you refine your search results. Here’s a comprehensive list of available filters:

Syntax Description
in:personal-direct Returns posts in personal messages between two users only
in:all-pms :information_source: For Admins only Returns posts from all personal messages, including those you’re not a part of
in:all Returns posts from public topics and personal messages
in:tagged Returns posts from topics that have at least one tag
in:untagged Returns posts from topics with no tags
in:seen Returns posts you’ve seen (for logged-in users)
in:unseen Returns posts you haven’t seen (for logged-in users)
in:wiki Returns wiki posts
in:watching Returns posts from topics you’re watching
in:tracking Returns posts from topics you’re tracking
posts_count:X Returns posts from topics that have exactly X posts
min_posts:X Returns posts from topics with at least X posts
max_posts:X Returns posts from topics with at most X posts
min_views:X Returns posts from topics with at least X views
max_views:X Returns posts from topics with at most X views
badge:name_or_id Returns posts linked to a specific badge grant
created:@username Returns posts from topics created by username
group:group_name Returns posts from users within the group_name group
group_messages:group_name Returns posts from personal messages sent to the group_name group
personal_messages:username :information_source: For Admins only Returns posts from personal messages of the specified user
-tags:tag1,tag2,tag3 Returns posts not tagged with tag1, tag2, or tag3
filetypes:ext1,ext2,ext3 Returns posts with uploads of ext1, ext2, or ext3 file extensions
categories:category1,category2 Returns posts from the categories category1 and category2
status:open Returns posts from topics that are not closed or archived
status:closed Returns posts from closed topics
status:archived Returns posts from archived topics
status:noreplies Returns posts from topics with no replies
status:single_user Returns posts from topics with posts from only one user
status:public Returns posts from topics in public categories
before:YYYY-MM-DD Returns posts created before the specified date
after:YYYY-MM-DD Returns posts created after the specified date
with:images Returns posts containing images

Order

You can sort your search results using the following order options:

Syntax Description
order:latest Sorts results from newest to oldest (shortcut: l)
order:oldest Sorts results from oldest to newest
order:latest_topic Sorts results by topic date, from newest to oldest
order:oldest_topic Sorts results by topic date, from oldest to newest
order:views Sorts results by number of views
order:likes Sorts results by number of likes
order:read (logged in only) sort by date you last visited topic (shortcut: r)

Aliases

Discourse provides several aliases to make searching easier:

Syntax Equivalent
l order:latest
in:personal in:messages
min_post_count: min_post:
in:mine in:created
category: categories:
# Can be used for both categories and tags, depending on context
user: @
@me @your_own_username
f in:first
t in:title

Searching for Exact Words

Discourse uses a technique called Stemming to find related words. While this is often helpful, there may be times when you want to search for an exact word. You can do this by enclosing your word with spaces and double quotes, like so: " term ".

This ensures that it will search only for the word “term” and exclude other related words.

:information_source: Note that because the spaces are considered part of the search term, it will not return “term” if it’s the first or the last word of a post since it won’t be preceded or followed by a space.

Example: Searching for @mentions

Currently, searching for @mentions is not directly supported. However, you can achieve this using the exact word search method:

https://community.nsfirehub.ca/search?q=“%20%40username%20”

:information_source: This works because %20 is how spaces are encoded in URLs and %40 is how the @ symbol is encoded.

This query will look specifically for @username (enclosed in spaces).

Combining Search Options

You can combine multiple search options to create more specific queries. For example:

  • status:open category:support tag:urgent after:2023-01-01 order:latest
    This will search for open support topics tagged as urgent, created after January 1, 2023, and sort the results by the latest post.

  • @jane_doe in:watching min_posts:5 with:images
    This will search for posts by Jane Doe in topics you’re watching, with at least 5 posts, and containing images.

Permissions and Limitations

Some advanced search options may require certain user permissions or may be limited to specific user roles. For example:

  • in:all-pms is only available to administrators, not to regular users or moderators.
  • personal_messages:username is only available to administrators.

Always consider your user role and permissions when using advanced search options.

Search Alternative: Topic List Filter

An experimental /filter feature is available that supports many filter types. You can learn more on the official topic: Experimental topics list filter feature - Feature - Discourse Meta

Source Files

For a more technical look at these options, all search filters and parameters can be found in search.rb - look for the advanced_filter methods.

Additional Tips

  1. You can also search for mentions of tags like #bug: https://meta.discourse.org/search?q=“%20%23bug”

  2. Some filters may be added by plugins. For example, the Solved plugin adds:

    • status:solved: Returns posts from solved topics
    • status:unsolved: Returns posts from unsolved topics in categories allowing solved marking
  3. The Topic Voting plugin adds an additional order option:

    • order:votes: Sort results by number of votes on the topic containing the post

:bulb: Take some time to experiment with different combinations of filters and options to find the most effective search strategy for your needs.