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

Screenshots or screen recordings

No UI changes.

How to set up and validate locally

  1. Enable the feature flag in rails console:
    Feature.enable(:zoekt_use_total_match_counts)
  2. Perform a Zoekt code search — result counts should reflect the total matches across all nodes rather than the trimmed response size.

MR acceptance checklist

Merge request reports

Loading