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
Screenshot_2025-12-11_at_18.42.14 Screenshot_2025-12-11_at_18.24.59
Screenshot_2025-12-12_at_00.49.44 Screenshot_2025-12-11_at_23.47.11

How to set up and validate locally

  1. 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".
  2. Test the rake task

    bundle exec rake gitlab:search:info
    • Verify the output includes Code Search enabled: line showing the status
  3. Test the deletion of Elastic data

    • Verify, you have blobs documents in Elasticsearch. Uncheck the setting Code 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.
  4. 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 the commits index, 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 the commits index and blobs in the main index.

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

Edited by Ravi Kumar

Merge request reports

Loading