Enable advanced user search regardless of namespace
What does this MR do and why?
Enables advanced search for the users scope even if namespace limiting is enabled.
The purpose of the change is to enable advanced search for all users who are able to use Elasticsearch to reduce the number of basic searches.
How
Adds a method to elasticsearchable.rb
which is set to true when the scope is users. This method is then used in Search::GroupService
and Search::ProjectService
to determine if elasticsearchable_scope
should be set or not (group
for GroupService
and project
for ProjectService
).
ApplicationSetting
determines if the search should be done using Elasticsearch or not based on elasticsearchable_scope
if namespace limiting is enabled.
This results in:
- if the scope is users,
elasticsearchable_scope
is alwaysnil
which means even if namespace limiting is enabled, advanced search will be performed. - if the scope is not users, nothing changes.
Impact
We expect less basic searches when a group or project is specified which accounts for most of the basic searches that take longer than 5 seconds:

How to set up and validate locally
- Ensure Elasticsearch is set up locally.
- Enable namespace limiting (go to
/admin/application_settings/advanced_search
and check the "Limit the number of namespaces and projects that can be indexed" box. - Set feature flags:
::Feature.enable(:advanced_user_search)
and::Feature.enable(:advanced_global_search_for_limited_indexing)
. - Perform a user search:
/search?scope=users&search=reported_user
and verify advanced search is used. - Select a group and verify advanced search is used.
- Select a project and verify advanced search is used.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #390337 (closed)