Advanced issue search should allow searching in issue comments
Problem to solve
Proposal
Proposing to implement this functionality within the work_items
index. For context, the issues
index is deprecated and will be removed in a future milestone. The plan is to store all issue notes in fields (one for internal, one for non-internal) in the work items index to allow for searching. Any comment create, update or delete will require indexing the related issue/work item.
Implementation plan
notes
and notes_internal
to work items index
MR 1: Add new fields - Create an Advanced search migration using the
Elastic::MigrationUpdateMappingsHelper
to add two new fields. The fields should have mapping settings:type: :text, index_options: 'positions', analyzer: :code_analyzer
- In
Search::Elastic::Types::WorkItem
, add the new fields tobase_mappings
method
MR 2: Populate new fields in work items index and keep in sync when notes change
- In
Search::Elastic::References::WorkItem
, populate the fields inbuild_indexed_json
inSearch::Elastic::References::WorkItem
. Guard the field population with::Elastic::DataMigrationService.migration_has_finished?
to ensure the migration adding the field has finished. Populate both fields by combining all notes of that type (notes_internal
ornotes
) into one string separated by newlines. - Add preloading for notes to the
preload_indexing_data
scope inWorkItem
model- In
EE::Note
model, queue thenoteable
for indexing by overriding a few methods. The methods should only queue for indexing for notes on issues-
maintain_elasticsearch_create
- when a note is created -
maintain_elasticsearch_update
- when a note is modified (only ifnote
orconfidential
is changed) -
maintain_elasticsearch_update
- when a note is deleted
-
- In
- specs updates
MR 3: Implement search
- In
Search::Elastic::WorkItemQueryBuilder
, add the new fields to the searched fields. This should be guarded by::Elastic::DataMigrationService.migration_has_finished?
and new feature flag - specs updates
MR 4: Backfilling
- In
Search::Elastic::References::WorkItem
, increase theSCHEMA_VERSION
constant to a newYY_MM
value. - Add a new migration using the
Elastic:: MigrationReindexBasedOnSchemaVersion
to backfill the new fields. I chose this migration helper because we need to backfill fields that may be empty