Add search filtering by programming language
_Note: This epic has ~backend tasks which must be performed in order and may not be able to be worked on in parallel_ ### Problem to solve Currently, in GitLab, there is no ability to filter searches by the programming language they are in. ### Further details When searching in a large project (esp. translated projects) a string can be repeated hundreds of times in translation files when you are simply looking for the original usage in code. Also, when searching for a particular function call that is popular across many languages it helps narrow the search if you know you only are looking for examples in Javascript. Adding this feature would greatly improve the usability of GitLab as an online source viewer/browser. ### Proposal Add a programming language facet to search results in Global Search, utilizing Elasticsearch aggregations. The first iteration of this will only be available for Advanced Search (Elasticsearch). #### Tasks - [x] Perform benchmarking for utilizing aggregations for this - [x] Determine if counts will be viable for this first iteration - [-] If counts won't be included, determine the appropriate sort order for options (perhaps alpha or grouping by similar languages?) - [x] gitlab~2492649 Add aggregations for blob search calls. Put behind feature flag to measure performance impact and allow easy rollback https://gitlab.com/gitlab-org/gitlab/-/issues/342642 - [x] ~backend perform roll out of feature flag https://gitlab.com/gitlab-org/gitlab/-/issues/342621 - [x] gitlab~2492649 Expose aggregations for blob search calls to the controller https://gitlab.com/gitlab-org/gitlab/-/issues/342643 - [x] gitlab~2492649 Add language filter support for blob searches https://gitlab.com/gitlab-org/gitlab/-/issues/342648 This is closed but needed to add some extra steps to add the new API that will be sued for Facets lists. - [x] ~backend Add language filter to search metadata https://gitlab.com/gitlab-org/gitlab/-/issues/342650 - [x] ~backend Move to Terms aggregation instead of Composite https://gitlab.com/gitlab-org/gitlab/-/issues/365052 - [x] ~backend Make aggregations a separate Elasticsearch call https://gitlab.com/gitlab-org/gitlab/-/issues/366581 - [x] ~backend Move backend call for aggregations to a separate internal API endpoint https://gitlab.com/gitlab-org/gitlab/-/issues/366661 - [x] gitlab~3412464 Add language facet to blob search result page https://gitlab.com/gitlab-org/gitlab/-/issues/342651 #### Acceptance Criteria * [ ] When viewing the results of a search, user is able to see language facets in the left sidebar based on the result set * [ ] User is able to select multiple language facets to apply and update the results * [ ] Each language option will display the number of results that match that language * [ ] Options will be sorted by number of results – most to least. * [ ] Option selection should be linkable (URL should include selections) * [ ] Show up to 10 language options initially. If more exist, include a "Show more" link which then displays the rest that we have fetched in aggregation (we are initially limiting this to 100 – [see discussion](https://gitlab.com/groups/gitlab-org/-/epics/6853#note_1001398284)) * [ ] Include a scrollable max-height on the options list (320px / 20rem) so it doesn't get too long * [ ] If more than 100 language options exist, include note at the bottom of the options list once "Show more" has been selected that indicates we are showing the top 100 language options * [ ] Include telemetry to track usage of language facet (based on effort, also include which options are being used) ### What does success look like, and how can we measure that? The ability to filter searches by programming language being present. (If no way to measure success, link to an issue that will implement a way to measure this) ### Links / references ![language-options](/uploads/8bbca91ccecec4ca676d153badb7850a/language-options.png) GitHub searching only Javascript examples: https://github.com/search?l=JavaScript&q=testing&type=Repositories <!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION --> *This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.* <!-- triage-serverless v3 PLEASE DO NOT REMOVE THIS SECTION -->
epic