Zoekt
DETAILS: Tier: Premium, Ultimate Offering: Self-managed Status: Beta
- Introduced as a beta in GitLab 15.9 with flags named
index_code_with_zoekt
andsearch_code_with_zoekt
. Disabled by default.- Enabled on GitLab.com in GitLab 16.6.
- Feature flags
index_code_with_zoekt
andsearch_code_with_zoekt
removed in GitLab 17.1.
WARNING: This feature is in beta and subject to change without notice. For more information, see epic 9404.
Zoekt is an open-source search engine designed specifically to search for code.
With this integration, you can use exact code search instead of advanced search to search for code in GitLab. You can use regular expression and exact match modes to search for code in a group or repository.
Install Zoekt
Prerequisites:
- You must have administrator access to the instance.
To enable exact code search in GitLab, you must have at least one Zoekt node connected to the instance. The following installation methods are supported for Zoekt:
- Zoekt chart (as a standalone chart or subchart of the GitLab Helm chart)
-
GitLab Operator (with
gitlab-zoekt.install=true
) - Docker Compose
- Ansible playbook (experiment)
Enable exact code search
Prerequisites:
- You must have administrator access to the instance.
- You must install Zoekt.
To enable exact code search in GitLab:
- On the left sidebar, at the bottom, select Admin.
- Select Settings > Search.
- Expand Exact code search configuration.
- Select the Enable indexing for exact code search and Enable exact code search checkboxes.
- Select Save changes.
Index root namespaces automatically
Prerequisites:
- You must have administrator access to the instance.
You can index both existing and new root namespaces automatically. To index all root namespaces automatically:
- On the left sidebar, at the bottom, select Admin.
- Select Settings > Search.
- Expand Exact code search configuration.
- Select the Index root namespaces automatically checkbox.
- Select Save changes.
When you disable this setting:
- Existing root namespaces remain indexed.
- New root namespaces are no longer indexed.
Pause indexing
Prerequisites:
- You must have administrator access to the instance.
To pause indexing for exact code search:
- On the left sidebar, at the bottom, select Admin.
- Select Settings > Search.
- Expand Exact code search configuration.
- Select the Pause indexing for exact code search checkbox.
- Select Save changes.
When you pause indexing for exact code search, all changes in your repository are queued. To resume indexing, clear the Pause indexing for exact code search checkbox.
Troubleshooting
When working with Zoekt, you might encounter the following issues.
Namespace is not indexed
When you enable the setting, new namespaces get indexed automatically.
If a namespace is not indexed automatically, inspect the Sidekiq logs to see if the jobs are being processed.
Search::Zoekt::SchedulingWorker
is responsible for indexing namespaces.
In a Rails console session, you can check:
-
Namespaces where Zoekt is not enabled:
Namespace.group_namespaces.root_namespaces_without_zoekt_enabled_namespace
-
The status of Zoekt indices:
Search::Zoekt::Index.all.pluck(:state, :namespace_id)
To index a namespace manually, run this command:
namespace = Namespace.find_by_full_path('<top-level-group-to-index>')
Search::Zoekt::EnabledNamespace.find_or_create_by(namespace: namespace)