Skip to content

Query the notes index for related issues

What does this MR do and why?

This MR introduces the ability to search for issue notes when searching for issues. This is only backend changes, there are no UI changes or any indication that the issue was returned because of a note match.

This is being done because the alternative approach to store notes in the work_items (issues) index did not work.

Everything is behind a feature flag.

AI Summary

This change enhances GitLab's search functionality by allowing issue searches to also find issues mentioned in notes. When a user searches for content, the system will now look not only at the issue title and description but also at related notes, making search results more comprehensive.

The implementation adds a new feature flag called search_work_item_queries_notes that controls this behavior. When enabled, the search system collects issue IDs from notes matching the search query and includes those issues in the results. The code also refactors the search query building process to make it more maintainable, extracting common functionality into helper methods.

The changes include updates to the Elasticsearch filters and queries to support this new capability, along with appropriate tests to verify the functionality works as expected. The code is structured to maintain backward compatibility while adding this new search enhancement.

References

Screenshots or screen recordings

Before After
image image

How to set up and validate locally

  1. enable gdk for elasticsearch
  2. index the instance using admin ui - search - advanced search --or-- by running gitlab:elastic:index rake task
  3. pick a few issues in a group or project
  4. add a comment to each issue (make sure the comment text isn't in the title or description)
  5. perform an issue search at each level, the issues should not come back in the result
    • global
    • group
    • project
  6. enable the feature flag search_work_item_queries_notes
  7. perform the same searches
    • global (this remains the same, issues will not come back for global search)
    • group (issues should come back)
    • project (issues should come back)

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