Skip to content

Commit 44fceda

Browse files
docs improvement
1 parent d8daccf commit 44fceda

File tree

1 file changed

+43
-32
lines changed

1 file changed

+43
-32
lines changed

docs/self-hosting/more/search-contexts.mdx

Lines changed: 43 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,16 @@ sidebarTitle: Search contexts (EE)
77
This is only available in the Enterprise Edition. Please add your [license key](/self-hosting/license-key) to activate it.
88
</Note>
99

10-
A **search context** is a user-defined grouping of repositories that helps focus searches on specific areas of your codebase, like frontend, backend, or infrastructure code. This reduces noise in search results and improves developer productivity.
10+
A **search context** is a user-defined grouping of repositories that helps focus searches on specific areas of your codebase, like frontend, backend, or infrastructure code. Some example queries using search contexts:
1111

12-
## Getting started
12+
- `context:data_engineering userId` - search for `userId` across all repos related to Data Engineering.
13+
- `context:k8s ingress` - search for anything related to ingresses in your k8's configs.
14+
- `( context:project1 or context:project2 ) logger\.debug` - search for debug log calls in project1 and project2
1315

14-
<Note>
15-
The following will walkthrough an example of how search contexts can be used. For a full reference, see [here](#schema-reference).
16-
</Note>
16+
17+
Search contexts are defined in the `context` object inside of a [declarative config](/self-hosting/more/declarative-config). Repositories can be included / excluded from a search context by specifying the repo's URL in either the `include` array or `exclude` array. Glob patterns are supported.
18+
19+
## Example
1720

1821
Let's assume we have a GitLab instance hosted at `https://gitlab.example.com` with three top-level projects, `web`, `backend`, and `shared`:
1922

@@ -36,51 +39,59 @@ shared/
3639
├─ ...
3740
```
3841

39-
To make searching easier, we can create three search contexts:
42+
To make searching easier, we can create three search contexts in our [config.json](/self-hosting/more/declarative-config):
4043
- `web`: For all frontend-related code
4144
- `backend`: For backend services and shared APIs
4245
- `pipelines`: For all CI/CD configurations
4346

44-
Add these contexts to your [config.json](/self-hosting/more/declarative-config):
4547

4648
```json
4749
{
4850
"$schema": "https://raw.githubusercontent.com/sourcebot-dev/sourcebot/main/schemas/v3/index.json",
49-
"connections": {
50-
"gitlab-connection": {
51-
"type": "gitlab",
52-
"url": "https://gitlab.example.com",
53-
"groups": ["web", "backend", "shared"]
54-
}
55-
},
5651
"contexts": {
5752
"web": {
58-
"description": "Frontend related repos.",
53+
// To include repositories in a search context,
54+
// you can reference them...
5955
"include": [
60-
"gitlab.example.com/web/**",
56+
// ... individually by specifying the repo URL.
57+
"gitlab.example.com/web/admin_panel/core",
58+
59+
60+
// ... or as groups using glob patterns. This is
61+
// particularly useful for including entire "sub-folders"
62+
// of repositories in one go.
63+
"gitlab.example.com/web/customer_portal/**",
6164
"gitlab.example.com/shared/react/**",
6265
"gitlab.example.com/shared/protobufs/**"
63-
]
64-
},
65-
"backend": {
66-
"description": "Backend related repos.",
67-
"include": [
68-
"gitlab.example.com/backend/**",
69-
"gitlab.example.com/shared/protobufs/**"
70-
]
66+
],
67+
68+
// Same with excluding repositories.
69+
"exclude": [
70+
"gitlab.example.com/web/customer_portal/pipelines",
71+
"gitlab.example.com/shared/react/hooks/**",
72+
],
73+
74+
// Optional description of the search context
75+
// that surfaces in the UI.
76+
"description": "Web related repos."
7177
},
72-
"pipelines": {
73-
"description": "Devops related repos.",
74-
"include": [
75-
"gitlab.example.com/web/pipelines/**",
76-
"gitlab.example.com/backend/pipelines/**",
77-
"gitlab.example.com/shared/pipelines/**"
78-
]
79-
}
78+
"backend": { /* ... specifies backend replated repos ... */},
79+
"pipelines": { /* ... specifies pipeline related repos ... */ }
80+
},
81+
"connections": {
82+
/* ...connection definitions... */
8083
}
8184
}
8285
```
8386

87+
<Accordion title="Repository URL details">
88+
Repo URLs are expected to be formatted without the leading http(s):// prefix. For example:
89+
- `github.com/sourcebot-dev/sourcebot` ([link](https://github.com/sourcebot-dev/sourcebot))
90+
- `gitlab.com/gitlab-org/gitlab` ([link](https://gitlab.com/gitlab-org/gitlab))
91+
- `chromium.googlesource.com/chromium` ([link](https://chromium-review.googlesource.com/admin/repos/chromium,general))
92+
</Accordion>
93+
94+
8495
Once configured, you can use these contexts in the search bar by prefixing your query with the context name. For example:
8596
- `context:web login form` searches for login form code in frontend repositories
8697
- `context:backend auth` searches for authentication code in backend services

0 commit comments

Comments
 (0)