Add API endpoint that delivers all indexed source branch names

Problem to solve

Merge request source branch filter is a dropdown with search field that needs to be populated with source branch names corresponding to all merge requests that are being currently shown. Possibly filtered by namespace or project.

The [SearchController#aggregations1 action](ee/app/controllers/ee/search_controller.rb) is defined in EE code. For the merge_requestsscope,aggregationsalready returns aggregations forlabels. We need a way to also return aggregations for source_branches`

Proposal

To accomplish this, the code will need to allow requesting aggregations for a scope and specific aggregation name

  • The aggregations method in Gitlab::Elastic:SearchResults returns aggregations for each supported scope. This method should be modified to also take in an aggregation name or type
  • Add a new aggregation to Search::Elastic::Aggregations
  • Gitlab::Search::AggregationParser may need to change to support source branches if additional data is needed that isn't indexed
  • [TBD] Search::Elastic::MergeRequestQueryBuilder assumes one aggregation, this will need to change. I'd like to make things more generic but I'll need to think on how to support many aggregations by the query builder 🤔
Edited by Terri Chu