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_mappingsmethod inSearch::Elastic::Types::WorkItem-
closed_atwith typedate -
healthwith typekeyword -
weightwith typelong -
milestone_due_datewith typedate -
milestone_start_datewith typedate -
label_nameswith type keyword assignee_nameswith 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_jsonmethod, add a gate to ensure the migration created above has completed - bump the
SCHEMA_VERSIONto a new value (YYYYWW, year and week number)
- populate the new field in the
- In the EE milestone model, all associated issues should be queued for indexing using
Elastic::ProcessBookkeepingService.track!when the milestone'sdue_dateorstart_dateis updated. - Check whether this
preload_indexing_dataN+1 spec should be updated for milestone since we are now also using 2 extra timestamps:- the specs for indexing are
ee/spec/services/elastic/process_bookkeeping_service_spec.rb
- the specs for indexing are
Backfilling data
- Add an advanced search migration to populate the new field using the
MigrationBackfillHelper- use
MigrationReindexBasedOnSchemaVersioninstead ofMigrationBackfillHelpersince these fields are nullable
- use
Edited by Alisa Frunza