Skip to content

Allow Zoekt search separately from Advanced search

Terri Chu requested to merge 432997-zoekt-should-work-by-itself into master

What does this MR do and why?

Related to #432997 (closed)

This MR separates Exact Code (aka Zoekt) search functionality from Advanced search. There are two spots where the scope is limited for a user:

  1. code in navigation.rb that directs the frontend on which tabs to show the user
  2. in [group/global]_service.rb that controls which scopes are allowed on the backend

This MR changes the functionality so either Advanced search or Zoekt can be enabled to show the code tab and allows the blobs scope.

Note:

  • Advanced search supports global (if FF is enabled), group, and project search
  • Exact code search supports group and project search

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

N/A

How to set up and validate locally

Presetup

  1. setup gdk for zoekt and enable it for a group
  2. setup gdk for advanced search and index the entire instance

Zoekt enabled only

  1. disable advanced search
     bundle exec rake gitlab:elastic:disable_search_with_elasticsearch
  2. perform a global code search: http://gdk.test:3000/search?scope=blobs&search=test
    • This should land on Projects search results, global code search is disabled
  3. perform a group level code search against Zoekt group: http://gdk.test:3000/search?search=test&group_id=107&scope=blobs
    • This should be serviced by Zoekt (confirm in performance bar or by message Exact code search (powered by Zoekt) is enabled)
  4. navigate to the project results (group level search)
    • the code tab should still be visible
  5. perform a project level code search against Zoekt project: http://gdk.test:3000/search?search=test&scope=blobs&project_id=39
    • This should be serviced by Zoekt (confirm in performance bar or by message Exact code search (powered by Zoekt) is enabled)
  6. disable zoekt in the user's preferences
  7. perform a group level code search against Zoekt group: http://gdk.test:3000/search?search=test&group_id=107&scope=blobs
    • This should land on Projects search results, code tab is not visible
  8. perform a project level code search against Zoekt project: http://gdk.test:3000/search?search=test&scope=blobs&project_id=39
    • This should be serviced by Postgres (confirm in performance bar, no zkt or es calls)
  9. repeat group and project searches for an anonymous user
    • Both should be be serviced by Zoekt (confirm in performance bar or by message Exact code search (powered by Zoekt) is enabled)

Both Zoekt and Advanced search enabled

Testing advanced search enabled group

  1. enable advanced search
    bundle exec rake gitlab:elastic:enable_search_with_elasticsearch
  2. perform a global code search: http://gdk.test:3000/search?scope=blobs&search=test
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  3. perform a group level code search against a non-Zoekt group
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  4. perform a project level code search against a non-Zoekt project
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  5. repeat group and project searches for an anonymous user
    • Both should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)

Testing Zoekt enabled group

  1. perform a group level code search against Zoekt group: http://gdk.test:3000/search?search=test&group_id=107&scope=blobs
    • This should be serviced by Zoekt (confirm in performance bar or by message Exact code search (powered by Zoekt) is enabled)
  2. navigate to project results
    • the code tab should still be visible
  3. perform a project level code search against Zoekt project: http://gdk.test:3000/search?search=test&scope=blobs&project_id=39
    • This should be serviced by Zoekt (confirm in performance bar or by message Exact code search (powered by Zoekt) is enabled)
  4. disable zoekt in the user's preferences
  5. perform a group level code search against Zoekt group: http://gdk.test:3000/search?search=test&group_id=107&scope=blobs
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  6. perform a project level code search against Zoekt project: http://gdk.test:3000/search?search=test&scope=blobs&project_id=39
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  7. repeat group and project searches for an anonymous user
    • This should be serviced by Zoekt (confirm in performance bar or by message Exact code search (powered by Zoekt) is enabled)

Only Advanced search enabled

  1. disable zoekt code search
::Feature.disable(:search_code_with_zoekt)
  1. perform a global code search: http://gdk.test:3000/search?scope=blobs&search=test
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  2. perform a group level code search against Zoekt group: http://gdk.test:3000/search?search=test&group_id=107&scope=blobs
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  3. navigate to project results
    • the code tab should still be visible
  4. perform a project level code search against Zoekt project: http://gdk.test:3000/search?search=test&scope=blobs&project_id=39
    • This should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
  5. repeat global, group and project steps for an anonymous user
    • Both should be serviced by Advanced search (confirm in performance bar or by message Advanced search is enabled)
Edited by Terri Chu

Merge request reports