Advanced search - add remaining missing fields to work item index

Problem to solve

We need to add missing WorkItem fields to work_items index in ES to continue integrating GLQL with ES. I grouped closed, health and weight together since they seem to be fields on the WorkItem model itself, so I think it will be relatively straightforward to add them in one go.

Update: We also want to denormalize milestone data and add milestone.start_date and milestone.due_date to the index to address the performance issue raised here when querying by by_milestone wildcard terms.

Update 2: I will also add label_names to unblock effort for this issue #541157 (comment 2529055331)

Implementation

Adding new field and keep updated

  • Add new fields to the index mapping in the base_mappings method in Search::Elastic::Types::WorkItem
    • closed_at with type date
    • health with type keyword
    • weight with type long
    • milestone_due_date with type date
    • milestone_start_date with type date
    • label_names with type keyword
    • assignee_names with type keyword
  • Add an advanced search migration to add the new field using the MigrationUpdateMappingsHelper
  • In Search::Elastic::References::WorkItem
    • populate the new field in the build_indexed_json method, add a gate to ensure the migration created above has completed
    • bump the SCHEMA_VERSION to a new value (YYYYWW, year and week number)
  • In the EE milestone model, all associated issues should be queued for indexing using Elastic::ProcessBookkeepingService.track! when the milestone's due_date or start_date is updated.
  • Check whether this preload_indexing_data N+1 spec should be updated for milestone since we are now also using 2 extra timestamps:

Backfilling data

  • Add an advanced search migration to populate the new field using the MigrationBackfillHelper
    • use MigrationReindexBasedOnSchemaVersion instead of MigrationBackfillHelper since these fields are nullable
Edited by Alisa Frunza