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
- Related to #533988 (closed)
- cannot be tested using multi-match because of Zoekt: Global code search doesn't work with the... (#534835 - closed)
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)
- setup gdk for zoekt
- create a root namespace with one subgroup in it
- create a project in top level namespace
- fork the same project into both root and subgroup
- enable the ff
zoekt_cross_namespace_search - search globally using graphQL with both params to test it out
- turn off ff for multi-match
zoekt_multimatch_frontend - check the response in the UI doing global search with
include forksfilter 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.