Skip to content

Add traversal_ids to notes index

What does this MR do and why?

This change adds support for traversal IDs to notes in Elasticsearch, which helps with hierarchical data navigation. The code introduces a new migration to add a "traversal_ids" field to the notes index, updates the schema version from 23.08 to 25.22, and modifies the note indexing logic to include these IDs when the migration is complete. The implementation also cleans up unused method arguments and empty else statements, improves code organization by removing redundant comments, and adds proper test coverage for the new functionality. This enhancement will likely improve search capabilities for notes across the GitLab hierarchy.

This MR is step 1 in improving notes query performance. Notes uses the legacy authorization in Elasticsearch queries which can send 1000s of project_id to Elasticsearch. This will improve performance for global and group searches (the same was previously done for code, merge requests, issues, etc). The query needs to be improved because it is now used during issue search. The plan for improving the query is:

  1. add traversal_ids to notes index
  2. backfill traversal_ids in notes index
  3. switch notes index to use new authorization in queries (behind a FF)
  4. remove FF

References

Screenshots or screen recordings

How to set up and validate locally

  1. setup elasticsearch in gdk
  2. open rails console
  3. run the migration: Elastic::MigrationWorker.new.perform
  4. verify in the elasticsearch.log file that the migration ran without error
  5. verify that the mapping now contains traversal_ids: curl localhost:9200/gitlab-development-notes/_mapping | jq

MR acceptance checklist

Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Terri Chu

Merge request reports

Loading