Use TotalFileMatchCount/TotalLineMatchCount for accurate Zoekt counts
What does this MR do and why?
Switches Gitlab::Search::Zoekt::Response#file_count and #match_count to prefer TotalFileMatchCount / TotalLineMatchCount from the coordinating node response, behind the zoekt_use_total_match_counts feature flag.
Why: The existing FileMatchCount / LineMatchCount fields reflect the trimmed result set returned in the JSON response. Once we cap max_file_match_results (issue #591910), these trimmed counts will reflect the cap (e.g. 20) rather than the true total — making displayed result counts like "5,000+ results" incorrect. The Total* fields are unaffected by trimming and accurately represent the full match count across all downstream Zoekt nodes.
Fallback behavior is preserved: if Total* fields are absent (e.g. older coordinating node versions), the existing logic applies.
References
- Closes #591911 (closed)
- Epic: &21173
- Rollout issue: #591922
Screenshots or screen recordings
No UI changes.
How to set up and validate locally
- Enable the feature flag in rails console:
Feature.enable(:zoekt_use_total_match_counts) - Perform a Zoekt code search — result counts should reflect the total matches across all nodes rather than the trimmed response size.
MR acceptance checklist
- I have evaluated the MR acceptance checklist for this MR.