From 0ab810e86f934a4ff970f0245554ba752e89e7e7 Mon Sep 17 00:00:00 2001 From: Maedah Batool Date: Tue, 29 Apr 2025 14:34:41 -0700 Subject: [PATCH] Default Search Context for Admins --- docs/code-search/working/search_contexts.mdx | 23 +++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/docs/code-search/working/search_contexts.mdx b/docs/code-search/working/search_contexts.mdx index a0dbbe2d0..501800d39 100644 --- a/docs/code-search/working/search_contexts.mdx +++ b/docs/code-search/working/search_contexts.mdx @@ -37,7 +37,9 @@ 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. @@ -45,6 +47,25 @@ If a user ever loses access to their default search context (eg. the search cont 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.