Add min char limitation to search autocomplete backend
Background
Search autocomplete endpoint does not enforce min character limit like /search
endpoint
There are three types of autocomplete data returned when a user types into the search bar:
- generic results
- results for Settings and Help
- these are hardcoded
- recently viewed items
- epics, issues, merge requests
- these use Redis
- resources
- groups, projects, users, issues
- these use a mix of Database and Elasticsearch
Proposal
Enforce the min character limit for resources
autocomplete data since that hits the database and Elasticsearch. The search_autocomplete_opts
method has three filter types (search, generic, and default) which return a variety of data.
- Combine the two character limits used in search params and search abuse detection
- remove
Gitlab::Search::AbuseDetection::MINIMUM_SEARCH_CHARS
- replace use with
Gitlab::Search::Params::MIN_TERM_LENGTH
- change
Gitlab::Search::Params::MIN_TERM_LENGTH
to 2
- remove
- The
resource_results
method should return an empty array if the term length is less than the min (useGitlab::Search::Params::MIN_TERM_LENGTH
)
Edited by Terri Chu