Fix how search type is determined
What does this MR do and why?
Search type can be one of basic
, advanced
or zoekt
.
Advanced and Zoekt need to be available in order to be used for searching, otherwise basic search is used.
If both Advanced and Zoekt are available, we use a priority check to determine what should be used. We also recently added the ability to choose a search type by adding a param search_type
but that didn't always guarantee the right backend was used. This MR fixes that.
We introduce a new concern called AdvancedAndZoektSearchable
(only in EE) and it sets the correct search_type
in GlobalService
, GroupService
or ProjectService
. It also uses the search_type
to determine which results to show.
frontend changes also had to be made because the search_type
is now the actual search type being used in the backend whereas previously it wasn't guaranteed. The frontend needs to know which search type is used for the search type indicator:
The frontend needed to change because the actual searchType is being passed from the backend.
For example for showing Advanced search is disabled since alunny/publish_lib is not the default branch
, before the searchType
was advanced
but basic
search was used.
Now, the searchType
is basic
and the indicator would have never showed. To fix that I exposed two new fields: advancedSearchAvailable
and zoektAvailable
which indicate if it is available but not used.
Follow-ups
In a follow-up MR I will deprecate the basic_search
parameter and update the documentation: Deprecate basic_search parameter (!162838 - merged)
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.
How to set up and validate locally
Change SearchServicePresenter
in ee/app/presenters/ee/search_service_presenter.rb
to return true|false:
-
advanced_search_enabled? = true
,zoekt_enabled? = true
- Do a blob search with a project selected, note that zoekt is used
- Do a blob search with a project selected and add
&search_type=zoekt
in the URL, note that zoekt is used - Do a blob search with a project selected and a different branch, note that zoekt is disabled
- Do a blob search with a project selected and add
&search_type=advanced
in the URL, note that advanced search is used - Do a blob search with a project selected, select a different branch and add
&search_type=advanced
in the URL, note that advanced search is disabled - Do a blob search with a project selected and add
&search_type=basic
in the URL, note that basic search is used
-
advanced_search_enabled? = false
,zoekt_enabled? = false
- Repeat the above and note that basic search is always used
Related to #477333 (closed)