Users autosuggestion: Issue and MR notes using search-as-you-type
Implement frontend changes required to make Issue and MR notes use Elasticsearch search-as-you-type
.
Context
Issue and MR note @mentions are notoriously slow when searching for a user for /assign
, /assign_reviwer
, /cc
, etc. An initial load makes an API call to fetch all possible users and store them in cache for subsequent searches. For the gitlab project, a few thousand users are returned and cached making the initial call take 3.37
seconds to receive a response from the backend.
The frontend uses a forked version of At.js
- https://gitlab.com/gitlab-org/frontend/At.js for doing autocomplete. My understanding is that we want to move away from this library. The autocomplete code can be found in app/assets/javascripts/gfm_auto_complete.js
.
In #367559, we want to move to using Elasticsearch to provide autocomplete results for users. The first feature we want to change is @mentions on Issue and MR notes but this could be extended to other features as well.
Implementation
Behind the feature flag autosuggest_users_using_elasticsearch
and when elasticsearch is available (use_elasticsearch?
is true
):
- Members autocomplete does not cache results on initial load so that every request makes a call to the API. The remaining types should not be changed.
- The API call should be made with an additional param
query
which is equal to the term the user enters. For atwho, the query is sent via the variablesubtext
. I.e. the equivalent ofparams[:query] = subtext