Backend merge request label facet: Introduce new document field

Problem to solve

This is a step towards providing feature parity with the merge requests list with filters. This will add backend support for indexing and searching labels for merge request documents

Proposal

This should be delivered across multiple MRs.

Introduce new field and backfill

  1. introduce an Advanced search migration to add a new field to the merge requests mappings named label_ids with type of keyword.
  1. In MergeRequestInstanceProxy populate label_ids (example in IssueInstanceProxy) and bump the schema_version (format is YY_MM)
  • Note: the label_ids should only be populated once the migration above is complete. You can use ::Elastic::DataMigrationService.migration_has_finished? to check
  1. add labels to preload_indexing_data in MergeRequestClassProxy
  2. update the 'does not have N+1 queries for merge_requests' spec for merge request indexing to add project and group labels to the merge requests created for testing N+1 in indexing
  3. update the spec for testing as_indexed_json.
  • add label_ids to the main 'returns json with all needed elements' test
  • add a spec to make sure label_ids are not populated if the migration is not complete (example spec)
  1. ensure that labels deleted will cause an update to indexed data that references the labels. see ee/app/models/ee/label_link.rb
Edited by Terri Chu