Respect fork filter for global zoekt search

What does this MR do and why?

This MR allows global search using exact code search to pass along the fork filters (both new exclude_forks and legacy include_forked params).

I also added a helper method for Search::Params so that slice can be used and added tests for it.

One important thing to note is that global search using Zoekt is not enabled for GitLab.com. It is only enabled via zoekt_cross_namespace_search (default false) feature flag.

AI summary

This change improves the handling of search filters in GitLab's blob search functionality. It removes the "Not available for global search" limitation from the excludeForks and includeForked parameters in the GraphQL API documentation. The code also refactors how boolean search parameters are processed by creating a centralized list of boolean parameters and adding a new slice method to the Search Params class that makes it easier to extract specific parameters. This simplifies the code in the Zoekt search service by allowing it to directly use the slice method instead of manually merging parameters. Tests were added to verify the new slice functionality works correctly with different parameter formats.

References

Screenshots or screen recordings

GraphQL tests below

How to set up and validate locally

Note: Can only be verified in graphQL if you have multi-match enabled due to #534835 (closed)

  1. setup gdk for zoekt
  2. create a root namespace with one subgroup in it
  3. create a project in top level namespace
  4. fork the same project into both root and subgroup
  5. enable the ff zoekt_cross_namespace_search
  6. search globally using graphQL with both params to test it out
  7. turn off ff for multi-match zoekt_multimatch_frontend
  8. check the response in the UI doing global search with include forks filter on and off

Note: On the master branch you can see includeForked has no impact on results.

test default behavior
{
  blobSearch(search: "not under active development",
    chunkCount: 5) {
    matchCount
    perPage
    fileCount
    searchType
    searchLevel
    files {
      path
      fileUrl
      chunks {
        matchCountInChunk
        lines {
          lineNumber
          text
        }
      }
    }
  }
}
test with `excludeForks`
{
  blobSearch(search: "not under active development",
    chunkCount: 5, 
    excludeForks: false) {
    matchCount
    perPage
    fileCount
    searchType
    searchLevel
    files {
      path
      fileUrl
      chunks {
        matchCountInChunk
        lines {
          lineNumber
          text
        }
      }
    }
  }
}
test with `includeForked`
{
  blobSearch(search: "not under active development",
    chunkCount: 5, 
    includeForked: true) {
    matchCount
    perPage
    fileCount
    searchType
    searchLevel
    files {
      path
      fileUrl
      chunks {
        matchCountInChunk
        lines {
          lineNumber
          text
        }
      }
    }
  }
}

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