Refactor Zoekt search mode
What does this MR do and why?
Add a new class Search::Gitlab::Zoekt::Query
which is responsible for modifying the search query entered by the user. The public method exact_search_query
will wrap the user-inputted query with the double quotes. If there is any syntax filter then it will not include these filters in the wrapped query. Currently, we are supporting these syntax filters: case, f, file, lang
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
Before | After |
---|---|
How to set up and validate locally
- Setup Zoekt for a namespace
- Make sure the checkbox
Enable Zoekt code search
under User Preferences is checked - Enable the feature flag
zoekt_exact_search
Feature.enable(:zoekt_exact_search)
- Perform a code search in the chosen namespace without any syntax filter.
- Open the
zkt
section in the performance bar. Ensure the searched term is wrapped with a double quote - Perform a code search in the chosen namespace with a syntax filter. For eg:
test case:no
. - Open the
zkt
section in the performance bar. Ensure the filter is not wrapped with the double quotes but onlytest
is wrapped. - Perform a code search in the chosen namespace with multiple syntax filters. For eg:
test case:no f:test/spec/constructor_spec.js
. - Open the
zkt
section in the performance bar. Ensure the filter is not wrapped with the double quotes but onlytest
is wrapped.
Related to #438213 (closed)
Edited by Ravi Kumar