Advanced Search: Expose the new setting in admin UI and info rake task
What does this MR do and why?
This change adds a new setting called "Code search with advanced search" to GitLab's admin panel that allows administrators to control whether code files are searched using Elasticsearch (a search engine technology).
When this setting is turned off, all code-related data is automatically deleted from the search index to save storage space and resources. This is particularly useful for organizations that have enabled Zoekt (an alternative code search tool) and want to avoid duplicating search functionality.
The implementation includes:
- A new checkbox in the admin settings interface
- Automatic cleanup that removes code data when the feature is disabled
- A background service that handles the deletion of code documents from the search index
- Updated documentation explaining the new option
- Comprehensive tests to ensure the feature works correctly
This gives administrators more granular control over their search infrastructure and helps optimize resource usage when multiple search tools are available.
We are not reindexing when the setting is re-enabled. It is decided here. #557401 (comment 2653410622)
References
Screenshots or screen recordings
| Before | After |
|---|---|
|
|
|
|
How to set up and validate locally
-
Verify the admin UI changes
- Navigate to Admin > Settings > Search > Advanced search
- Confirm the new "Code search with advanced search" checkbox appears between "Search with advanced search" and "Requeue indexing workers".
-
Test the rake task
bundle exec rake gitlab:search:info- Verify the output includes
Code Search enabled:line showing the status
- Verify the output includes
-
Test the deletion of Elastic data
- Verify, you have
blobsdocuments in Elasticsearch. Uncheck the settingCode search with advanced search, now verify all the blob data is removed from Elasticsearch. Blob data is in the main index. No other documents are removed from the Elastic.
- Verify, you have
-
Test incremental indexing is not creating new documents
- Uncheck
Search with advanced search. Add a commit to a default branch. Verify, commits get indexed in thecommitsindex, but not the blobs in the main index. - Check
Search with advanced search. Add a commit to a default branch. Verify, commits get indexed in thecommitsindex and blobs in the main index.
- Uncheck
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Related to #557400 (closed)



