Add fork and archive filters to search API

What does this MR do and why?

Add fork and archive filters to search API

AI SUmmary

This merge request makes several improvements to GitLab's search functionality:

Main Changes:

  • Code Quality: Fixes code style violations by adding proper comments to explain why certain feature flags don't need specific user context, removing one file from the style violation list.

  • Performance Optimization: Improves how merge requests load related data by conditionally including different database relationships based on a feature flag, and optimizes commit pipeline loading to reduce unnecessary database queries.

  • API Documentation: Updates the search API documentation to add two new search parameters:

    • include_archived: Allows including archived projects in search results (defaults to false)
    • exclude_forks: Allows excluding forked projects from search results (defaults to true)
  • Search Feature Enhancement: Adds support for "exact code search" using Zoekt technology as an alternative to the existing advanced search (Elasticsearch). This includes comprehensive test coverage for the new search capabilities.

  • Code Cleanup: Renames variables and comments to use more generic terms like "advanced search" instead of "Elasticsearch" to better reflect that multiple search technologies are now supported.

The changes primarily focus on making search more flexible and performant while maintaining backward compatibility.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

Tested using basic, advanced, or exact code search. You can check out gdk setup for setting up zoekt and elasticsearch.

Setup a group with 1 non-archived and 1 archived project and 1 forked project that has some data (at least issue and code). Run searches for global, group, and project level searches.

level search type what filters should work
global basic include_archived
group basic include_archived
project basic NONE - include_archived should be ignored when searching in an archived project
global advanced include_archived
group advanced include_archived
project advanced NONE - include_archived should be ignored when searching in an archived project
global (blobs scope only) zoekt include_archived, exclude_forks
group (blobs scope only) zoekt include_archived, exclude_forks
project (blobs scope only) zoekt NONE - should be ignored when searching in an archived or forked project

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.

Edited by Terri Chu

Merge request reports

Loading