sam

read lib/search.rb, spec/lib/search_spec.rb in discourse/discourse and then provide with a beautifully formatted markdown user guide for all the various search options.

The guide should be exhaustive and cover every single search option.

claude-3.5-sonnet GitHub Helper

Certainly! I’ll retrieve the content of the specified files, analyze them, and create a comprehensive markdown user guide for all the search options in Discourse. Let’s start by fetching the files:

GitHub file content

Retrieved content of lib/search.rb, spec/lib/search_spec.rb from discourse/discourse@main

Based on the provided code for the Search class in Discourse, I’ll create a comprehensive markdown user guide for all the various search options. This guide will cover both basic and advanced search functionalities.

Discourse Search Options User Guide

Discourse provides a powerful search system with various options to help you find the content you’re looking for. This guide will walk you through all the available search options.

Basic Search

To perform a basic search, simply type your search terms into the search bar. Discourse will search for these terms in posts, topics, and other relevant content.

Advanced Search Options

Discourse supports several advanced search options that allow you to refine your search results. You can use these options by adding them to your search query.

Search Filters

  1. in:title or t - Search for topics with the term in the title
    Example: ruby in:title or ruby t

  2. in:personal - Search within personal messages
    Example: important in:personal

  3. in:messages - Same as in:personal

  4. in:personal-direct - Search within direct personal messages (without group messages)
    Example: urgent in:personal-direct

  5. in:all-pms - Search within all personal messages (admin only)
    Example: confidential in:all-pms

  6. in:all - Search all topics (includes unlisted topics)
    Example: announcement in:all

  7. in:first or f - Limit search to first posts of topics
    Example: introduction in:first or introduction f

  8. in:pinned - Search within pinned topics
    Example: important in:pinned

  9. in:wiki - Search within wiki posts
    Example: guide in:wiki

  10. in:tagged - Search for topics with any tags
    Example: question in:tagged

  11. in:untagged - Search for topics without tags
    Example: help in:untagged

  12. in:seen - Search within posts you’ve seen (for logged-in users)
    Example: tutorial in:seen

  13. in:unseen - Search within posts you haven’t seen (for logged-in users)
    Example: news in:unseen

  14. in:posted - Search within topics you’ve posted in
    Example: solution in:posted

  15. in:created or in:mine - Search within topics you’ve created
    Example: project in:created or project in:mine

  16. in:watching - Search within topics you’re watching
    Example: update in:watching

  17. in:tracking - Search within topics you’re tracking
    Example: progress in:tracking

User and Group Filters

  1. @{username} - Search for posts by a specific user
    Example: @john_doe solution

  2. user:{username} - Same as @{username}
    Example: user:jane_doe proposal

  3. group:{group_name} - Search for posts by users in a specific group
    Example: group:moderators announcement

  4. group_messages:{group_name} - Search within group messages
    Example: group_messages:staff confidential

  5. personal_messages:{username} - Search within personal messages with a specific user (admin only)
    Example: personal_messages:john_doe urgent

Category and Tag Filters

  1. category:{category_name} or #{category_name} - Search within a specific category
    Example: category:general question or #general question

  2. categories:{category_name_1},{category_name_2} - Search within multiple categories
    Example: categories:general,support issue

  3. tag:{tag_name} - Search for topics with a specific tag
    Example: tag:bug report

  4. tags:{tag_name_1},{tag_name_2} - Search for topics with multiple tags
    Example: tags:feature,ux proposal

  5. -tags:{tag_name_1},{tag_name_2} - Exclude topics with specific tags
    Example: -tags:resolved,invalid issue

Status Filters

  1. status:open - Search for topics that are not closed or archived
    Example: status:open question

  2. status:closed - Search for closed topics
    Example: status:closed resolved

  3. status:archived - Search for archived topics
    Example: status:archived old-feature

  4. status:noreplies - Search for topics with no replies
    Example: status:noreplies help

  5. status:single_user - Search for topics with posts from only one user
    Example: status:single_user guide

  6. status:public - Search for topics in public categories
    Example: status:public announcement

Date Filters

  1. before:{date} - Search for posts before a specific date
    Example: before:2021-01-01 legacy

  2. after:{date} - Search for posts after a specific date
    Example: after:2022-01-01 new-feature

Other Filters

  1. min_posts:{n} - Search for topics with at least n posts
    Example: min_posts:10 discussion

  2. max_posts:{n} - Search for topics with at most n posts
    Example: max_posts:5 question

  3. min_views:{n} - Search for topics with at least n views
    Example: min_views:1000 popular

  4. max_views:{n} - Search for topics with at most n views
    Example: max_views:100 recent

  5. created:@{username} - Search for topics created by a specific user
    Example: created:@jane_doe project

  6. with:images - Search for posts containing images
    Example: with:images screenshot

  7. filetypes:{extension} - Search for posts with attachments of specific file types
    Example: filetypes:pdf,doc report

  8. min_views:{n} - Search for topics with at least n views
    Example: min_views:1000 popular

  9. max_views:{n} - Search for topics with at most n views
    Example: max_views:100 recent

  10. posts_count:{n} - Search for topics with exactly n posts
    Example: posts_count:1 announcement

  11. min_post_count:{n} - Search for topics with at least n posts
    Example: min_post_count:20 discussion

  12. max_posts:{n} - Search for topics with at most n posts
    Example: max_posts:5 question

Sorting Results

You can sort search results using the following options:

  1. order:latest or l - Sort by latest post
    Example: bug order:latest or bug l

  2. order:oldest - Sort by oldest post
    Example: feature order:oldest

  3. order:latest_topic - Sort by latest topic
    Example: announcement order:latest_topic

  4. order:oldest_topic - Sort by oldest topic
    Example: legacy order:oldest_topic

  5. order:views - Sort by number of views
    Example: tutorial order:views

  6. order:likes - Sort by number of likes
    Example: funny order:likes

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.

Remember that some advanced search options may require certain user permissions or may be limited to specific user roles (e.g., administrators).