Skip to content

Default Search Context for Admins #1108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion docs/code-search/working/search_contexts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,35 @@ You can also search across multiple contexts at once using the `OR` [boolean ope

To organize your search contexts better, you can use a specific context as your default and star any number of contexts. This affects what context is selected when loading Sourcegraph and how the list of contexts is sorted.

### Default context
### Default search context

#### For users

Any authenticated user can use a search context as their default. To set a default, go to the search context management page, open the "..." menu for a context, and click on "Use as default". If the user doesn't have a default, `global` will be used.

If a user ever loses access to their default search context (eg. the search context is made private), they will see a warning at the top of the search contexts dropdown menu list and `global` will be used. If a user's default search context is deleted, `global` will immediately be set as their default.

The default search context is always selected when loading the Sourcegraph webapp. The one exception is when opening a link to a search query that does not contain a `context:` filter, in which case the `global` context will be used.

#### For site admins

Site admins can set a default search context for all users on the Sourcegraph instance. This helps teams improve onboarding and search quality by focusing searches on the most relevant parts of the codebase rather than the entire indexed set of repositories.

An admin can set a default search context via:

- Click the **More** button from the top menu of the Sourcegraph web app
- Next, go to **Search Contexts**
- For the existing context list, click on the **...** menu and select **[Site admin only] Set as default for all users**
- Alternatively, you can create a new context and then set it for all users via the same option

![admin-level-default-context](https://storage.googleapis.com/sourcegraph-assets/Docs/admin-default-context.png)

Here are a few considerations:

- If a user already has a personal default search context set, it will not be overridden
- The admin-set default will apply automatically if a user only uses the global context
- Individual users can see the instance-wide default and override it with their own default if they choose

### Starred contexts

Any authenticated user can star a search context. To star a context, click on the star icon in the search context management page. This will cause the context to appear near the top of their search contexts list. The `global` context cannot be starred.
Expand Down