[Backport]Autocomplete: Change user authorization to use terms query for projects
What does this MR do and why?
(cherry picked from commit db392509)
Autocomplete: Change user authorization to use ... (!187862 - merged)
Description from original MRUpdate the Elasticsearch query used for filtering users during autocomplete to prevent too_many_clauses
errors as reported in #534033 (closed). This is seen when the current user has many authorized groups or projects.
The change combines all the ids for authorized projects into one terms
query instead of having one prefix
query per project, thereby reducing the number of clauses.
Before
{:query=>
{:bool=>
{:must=>[{:simple_query_string=>{:_name=>"user:match:search_terms", :fields=>["name", "username", "public_email"], :query=>"maddiev~", :lenient=>true, :default_operator=>:and}}],
:should=>[],
:filter=>
[{:term=>{:type=>{:_name=>"doc:is_a:user", :value=>"user"}}},
{:term=>{:in_forbidden_state=>{:value=>false, :_name=>"filter:not_forbidden_state"}}},
{:bool=>
{:should=>
[{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>22}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>24}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>27}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>29}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>"1-p15-"}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>"31-p6-"}}}],
:minimum_should_match=>1}}]}},
:highlight=>{:fields=>{:name=>{}, :username=>{}, :public_email=>{}}, :number_of_fragments=>0, :pre_tags=>["gitlabelasticsearch→"], :post_tags=>["←gitlabelasticsearch"]}}
After
{:query=>
{:bool=>
{:must=>[{:simple_query_string=>{:_name=>"user:match:search_terms", :fields=>["name", "username", "public_email"], :query=>"maddiev~", :lenient=>true, :default_operator=>:and}}],
:should=>[],
:filter=>
[{:term=>{:type=>{:_name=>"doc:is_a:user", :value=>"user"}}},
{:term=>{:in_forbidden_state=>{:value=>false, :_name=>"filter:not_forbidden_state"}}},
{:bool=>
{:minimum_should_match=>1,
:should=>
[{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>22}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>24}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>27}}},
{:prefix=>{:namespace_ancestry_ids=>{:_name=>"namespace:ancestry_filter:descendants", :value=>29}}},
{:terms=>{:namespace_ancestry_ids=>["1-p15-", "31-p6-"], :_name=>"namespace:ancestry_filter:project_ids"}}]}}]}},
:highlight=>{:fields=>{:name=>{}, :username=>{}, :public_email=>{}}, :number_of_fragments=>0, :pre_tags=>["gitlabelasticsearch→"], :post_tags=>["←gitlabelasticsearch"]}}
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
This MR is backporting a bug fix, documentation update, or spec fix, previously merged in the default branch. -
The MR that fixed the bug on the default branch has been deployed to GitLab.com (not applicable for documentation or spec changes). -
This MR has a severity label assigned (if applicable). -
Set the milestone of the merge request to match the target backport branch version. -
This MR has been approved by a maintainer (only one approval is required). -
Ensure the e2e:test-on-omnibus-ee
job has either succeeded or been approved by a Software Engineer in Test.
Note to the merge request author and maintainer
If you have questions about the patch release process, please:
- Refer to the patch release runbook for engineers and maintainers for guidance.
- Ask questions on the
#releases
Slack channel (internal only).
Edited by Terri Chu