Skip to content

Fix how search type is determined

Madelein van Niekerk requested to merge 477333-fix-search-type into master

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:

Screenshot_2024-08-12_at_16.06.35

Screenshot_2024-08-12_at_16.06.51

Screenshot_2024-08-12_at_16.07.06

Screenshot_2024-08-12_at_16.07.29

Screenshot_2024-08-12_at_16.07.41

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:

  1. advanced_search_enabled? = true, zoekt_enabled? = true
    1. Do a blob search with a project selected, note that zoekt is used
    2. Do a blob search with a project selected and add &search_type=zoekt in the URL, note that zoekt is used
    3. Do a blob search with a project selected and a different branch, note that zoekt is disabled
    4. Do a blob search with a project selected and add &search_type=advanced in the URL, note that advanced search is used
    5. 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
    6. Do a blob search with a project selected and add &search_type=basic in the URL, note that basic search is used
  2. advanced_search_enabled? = false, zoekt_enabled? = false
    1. Repeat the above and note that basic search is always used

Related to #477333 (closed)

Edited by Madelein van Niekerk

Merge request reports

Loading