Part 1: Advanced search - add mappings for the remaining missing fields in work item index

What does this MR do and why?

This MR adds support for the following fields in the elasticsearch work_items index to enable GLQL search capabilities:

  • closed_at: date field to filter work_item by the date it was closed
  • health_status: short type field to filter work_item by its health status (on_track, needs_attention, at_risk)
  • weight: integer type field to filter work_item by its weight
  • milestone_start_date: date field to filter work_item by milestone's start date
  • milestone_due_date: date field to filter work_item by milestone's due date
  • label_names: keyword field to filter work_item by its labels
  • assignee_usernames: keyword field to filter by users assigned to work_item

The milestone_start_date and milestone_due_date fields are added to allow implementing ES search by the following existing pg scopes:

References

Screenshots or screen recordings

Before After

How to set up and validate locally

  1. Follow this guide to have ES enabled locally for GDK
  2. In rails c manually trigger the migration to run with Elastic::MigrationWorker.new.perform
  3. You can then check that the new fields were added to the work items mapping with curl http://localhost:9200/gitlab-development-work_items/_mappings | jq .
  4. Pick an issue and make sure to update its labels, health and weight, then check in ES that these fields were successfully populated there (see step 8 on how to do it).
  5. Then close this issue; then also check that closed_at was reflected in ES as well (see step 8 on how to do it).
  6. Create a milestone with start and due dates and assign it to the issue. Check that milestone_start_date and milestone_due_date are now also updated in ES (see step 8 on how to do it).
  7. Another test is for elastic_index_dependant_association to make sure that when we edit either start or due dates on a milestone, this change is also reflected in ES index (see step 8 on how to do it).
  8. You can use the below snipped to test that we have the proper values in the ES index (make sure to set the correct issue id to "id" field in terms query; "_source" specifies which fields you to fetch, if you remove it, you'd get all fields returned):
curl -X GET "http://localhost:9200/gitlab-development-work_items/_search" \
     -H "Content-Type: application/json" \
     -d '{
           "query": {
             "term": {
               "id": 652
             }
           },
           "_source": ["milestone_start_date", "milestone_due_date", "health", "weight", "closed_at", "label_titles"]
         }'

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.

Related to #540792 (closed)

Edited by Alisa Frunza

Merge request reports

Loading