Repository search only shows one match per file

Summary

Repository search only shows one match per file, this means that the count on the left-hand side is wrong.

Steps to reproduce

  1. Go to any repository
  2. Do a search where a file should contain multiple matches
  3. Only one match is shown for the file

Example Project

For the project https://gitlab.com/gitlab-org/gitaly, we can check on the CLI that the file internal/gitaly/service/hook/pack_objects_test.go has 5 matches for the search of gittest.SeedGitLabTest

image

But the search (https://gitlab.com/search?group_id=9970&project_id=2009901&repository_ref=master&scope=blobs&search=SeedGitLabTest+filename%3A*pack_objects_test.go) only yields one result.

Overall on the CLI there are 130 matches for the text gittest.SeedGitLabTest in the whole repository:

❯ git grep gittest.SeedGitLabTest | wc -l
130

but the search only shows 50 results (https://gitlab.com/search?group_id=9970&project_id=2009901&repository_ref=master&scope=blobs&search=gittest.SeedGitLabTest)

What is the current bug behavior?

  1. Search only shows one match per file (even if there are more instances in the file)

What is the expected correct behavior?

  1. Search should show all matches in a file

Relevant logs and/or screenshots

Added above

Output of checks

This bug happens on GitLab.com

Results of GitLab environment info

N/A

Expand for output related to GitLab environment info

(For installations with omnibus-gitlab package run and paste the output of:
`sudo gitlab-rake gitlab:env:info`)

(For installations from source run and paste the output of:
`sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)

Results of GitLab application Check

Expand for output related to the GitLab application check

(For installations with omnibus-gitlab package run and paste the output of: sudo gitlab-rake gitlab:check SANITIZE=true)

(For installations from source run and paste the output of: sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true)

(we will only investigate if the tests are passing)

Possible fixes

Edited Jan 09, 2023 by Karthik Nayak
Assignee Loading
Time tracking Loading