Skip to main content
only available in a paid plan. Please activate a license key to use this feature.
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:
  • context:data_engineering userId - search for userId across all repos related to Data Engineering.
  • context:k8s ingress - search for anything related to ingresses in your k8’s configs.
  • ( context:project1 or context:project2 ) logger\.debug - search for debug log calls in project1 and project2
Search contexts are defined in the context object inside of a 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.

Example

Let’s assume we have a GitLab instance hosted at https://gitlab.example.com with three top-level groups, web, backend, and shared:
To make searching easier, we can create three search contexts in our config.json:
  • web: For all frontend-related code
  • backend: For backend services and shared APIs
  • pipelines: For all CI/CD configurations
Repo URLs are expected to be formatted without the leading http(s):// prefix. For example:
  • github.com/sourcebot-dev/sourcebot (link)
  • gitlab.com/gitlab-org/gitlab (link)
  • chromium.googlesource.com/chromium (link)
Once configured, you can use these contexts in the search bar by prefixing your query with the context name. For example:
  • context:web login form searches for login form code in frontend repositories
  • context:backend auth searches for authentication code in backend services
  • context:pipelines deploy searches for deployment configurations
Example Like other prefixes, contexts can be negated using - or combined using or:
  • -context:web excludes frontend repositories from results
  • ( context:web or context:backend ) searches across both frontend and backend code
See this doc for more details on the search query syntax.

Filtering by topic

If your repositories are tagged with topics on GitHub or GitLab, you can use includeTopics and excludeTopics to filter repositories by topic instead of (or in addition to) specifying individual repo URLs. Glob patterns are supported.
includeTopics and excludeTopics follow the same additive semantics as include and exclude:
  • includeTopics adds all repos tagged with a matching topic to the context.
  • excludeTopics removes repos tagged with a matching topic from the context.
  • Both can be freely combined with include, includeConnections, exclude, and excludeConnections.
Topic matching is case-insensitive, so "Backend" matches the pattern "backend".
Topics are populated when a connection syncs. If you add topics to your repositories after the last sync, trigger a re-sync for the new topics to take effect.

Schema reference

schemas/v3/searchContext.json