Long query times when using `path` filter in Advanced Search and Search API
Summary
When using the path
filter in Advanced Search and Search API, the time to complete the query is very high. In some customer's cases, they are receiving a lot of timeouts.
Steps to reproduce
@changzhengliu was able to reproduce this behaviour on GitLab.com as part of an internal discussion:
I looked at our Workhorse log, and it seems all the failed queries on that group used the
path
filter. It seems Elasticsearch does not handle the filter very well, which may also have to do with our design. For example, if we make this query on GitLab.com, it returns relatively fast. If we add a path filter to that query, it becomes quite slow.
Example Project
What is the current bug behavior?
Queries using path
filter are taking a long time, in some cases they reliably produce Rack timeouts.
What is the expected correct behavior?
Queries using path
filter could be more performant.
Relevant logs and/or screenshots
Output of checks
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)