Allow projects under user namespaces to be indexed in Zoekt for self-managed instances
Summary
Enable Zoekt code search indexing for projects under user namespaces (personal projects) on self-managed GitLab instances. Currently, only group namespaces are indexed.
Problem
The auto_index_self_managed task in Search::Zoekt::SchedulingService only indexes group namespaces:
Namespace.group_namespaces.root_namespaces_without_zoekt_enabled_namespace.each_batch do |batch|
data = batch.pluck_primary_key.map { |id| { root_namespace_id: id } }
Search::Zoekt::EnabledNamespace.insert_all(data)
end
This means personal projects (projects under user namespaces) are excluded from Zoekt indexing on self-managed instances.
Proposed Solution
Remove the group_namespaces filter to include both group and user namespaces:
Current code (line 273):
Namespace.group_namespaces.root_namespaces_without_zoekt_enabled_namespace.each_batch do |batch|
Proposed change:
Namespace.root_namespaces_without_zoekt_enabled_namespace.each_batch do |batch|
This will allow both:
- Group namespaces (existing behavior)
- User namespaces (new behavior - personal projects)
Important Notes
This should NOT be done on GitLab.com (SaaS)
The task already has a guard to prevent running on SaaS:
def auto_index_self_managed
return if Gitlab::Saas.feature_available?(:exact_code_search)
# ...
end
This ensures the change only affects self-managed instances where zoekt_auto_index_root_namespace is enabled.
Benefits
- Complete code search coverage - All projects get indexed, not just group projects
- Better user experience - Personal projects can use exact code search
- Consistency - Matches user expectations that all projects should be searchable
Implementation
File to modify: ee/app/services/search/zoekt/scheduling_service.rb
Change line 273 from:
Namespace.group_namespaces.root_namespaces_without_zoekt_enabled_namespace.each_batch do |batch|
To:
Namespace.root_namespaces_without_zoekt_enabled_namespace.each_batch do |batch|
Related
- Related to #582308 (Exact Code Search - Missing Results in global search)