Skip to content

Project Search uses PostgreSQL for count requests when searching non default branch

Summary

Project scoped searches will only go to Advanced Search if the repository_ref parameter provided is the root ref. This makes sense for only some of the scopes (code, wiki, commit), but it doesn't make sense for others (projects, issues, merge requests, notes). This is putting unnecessary load on the database when the requests could be handled by Elasticsearch

Steps to reproduce

  1. ensure advanced search is setup and enabled
  2. perform a code search in a project
  3. choose a non root repository ref from the dropdown
  4. use the performance bar to look at the /search/count requests for issues or merge requests
  5. note that none of them have elasticsearch calls and go to the database instead

What is the current bug behavior?

All count requests go to the database regardless of whether repository has any impact on data being in Elasticsearch

What is the expected correct behavior?

Only count requests for scopes where the repository has an impact on the data being stored in Elasticsearch should take into account the repository_ref parameter

Possible fixes