Issue & blob aggregations for group searches do not use traversal_ids
Summary
Group searches do not use the traversal_ids
optimization for the search/aggregation endpoint (currently available for issues and blobs scopes)
Steps to reproduce
- enable advanced search
- run a group scoped code search (must be
- open performance bar and look at the Elasticsearch query generated for the GET
aggregations
call - note that it does not contain
traversal_ids
and instead contains a list ofproject_id
Relevant logs and/or screenshots
example call for search with traversal_ids
POST gitlab-development/_search?routing=project_53%2Cproject_40%2Cproject_33%2Cproject_1&timeout=30s { "query": { "bool": { "must": { "simple_query_string": { "_name": "blob:match:search_terms", "fields": [ "blob.content", "blob.file_name", "blob.path" ], "query": "test", "default_operator": "and" } }, "must_not": [ { "terms": { "_name": "blob:authorized:reject_projects", "project_id": [] } } ], "should": [], "filter": [ { "bool": { "should": [ { "prefix": { "traversal_ids": { "_name": "blob:authorized:namespace:ancestry_filter:descendants", "value": "22-" } } } ] } }, { "term": { "type": { "_name": "doc:is_a:blob", "value": "blob" } } } ] } }, "size": 20, "from": 0, "sort": [ "_score" ], "highlight": { "pre_tags": [ "gitlabelasticsearch→" ], "post_tags": [ "←gitlabelasticsearch" ], "number_of_fragments": 0, "fields": { "blob.content": {}, "blob.file_name": {} } } }
example call for aggregation missing traversal_ids
POST gitlab-development/_search?routing=project_53%2Cproject_40%2Cproject_33%2Cproject_1&timeout=30s { "query": { "bool": { "must": { "simple_query_string": { "_name": "blob:match:search_terms", "fields": [ "blob.content", "blob.file_name", "blob.path" ], "query": "test", "default_operator": "and" } }, "must_not": [], "should": [], "filter": [ { "bool": { "should": [ { "bool": { "filter": [ { "terms": { "_name": "blob:authorized:project:membership:id", "project_id": [ 1, 33, 40, 53 ] } }, { "terms": { "_name": "blob:authorized:project:repository:enabled_or_private", "repository_access_level": [ 20, 10 ] } } ] } } ], "_name": "blob:authorized:project" } }, { "term": { "type": { "_name": "doc:is_a:blob", "value": "blob" } } } ] } }, "size": 0, "aggs": { "language": { "terms": { "field": "blob.language", "size": 100 } } } }
Possible fixes
Root cause is due to the base_options
not containing the group_ids
field. That is added in scope_options
in the overridden method in group_search_results.rb
.
Blob and issue aggregations use base_options
method