Advanced search - allow queries for health in work item index
What does this MR do and why?
This MR adds support for GLQL health status query in Elasticsearch.
Currently, health status holds the following 3 enum values: "on track", "at risk", and "needs attention". In both Postgres and ES, these values are saved as integer. So I am going to map them to their corresponding numeric values on Glql::WorkItemFinder level.
enum :health_status, {
on_track: 1,
needs_attention: 2,
at_risk: 3
}
Below is the example mapping (GLQL field => Glql::WorkItemsFinder parameters => Search::Elastic::Filter parameter) of all possible variations for health field:
Specific Health Status Queries
| GLQL Query | WorkItems Finder | ES Filter Name |
|---|---|---|
health = "on track" |
health_status_filter: "on_track" |
health_status: 1 |
health != "on track" |
not: {health_status_filter: ["on_track"]} |
not_health_status: 1 |
health = "at risk" |
health_status_filter: "at_risk" |
health_status: 3 |
health = "needs attention" |
health_status_filter: "needs_attention" |
health_status: 2 |
Wildcard Health Status Queries
| GLQL Query | WorkItems Finder | ES Filter Name |
|---|---|---|
health = any |
health_status_filter: "any" |
any_health_status: true |
health != any |
health_status_filter: "none" |
none_health_status: true |
health = none |
health_status_filter: "none" |
none_health_status: true |
health != none |
health_status_filter: "any" |
any_health_status: true |
Combined Health Status Queries
| GLQL Query | WorkItems Finder | ES Filter Name |
|---|---|---|
health = "on track" and health != none |
health_status_filter: "on_track" |
health_status: 1 |
health != "on track" and health = any |
not: {health_status_filter: ["on_track"]}, health_status_filter: "any" |
not_health_status: 1, any_health_status: true |
References
Screenshots or screen recordings
| Before | After |
|---|---|
How to set up and validate locally
- Follow this guide to have ES enabled locally for GDK
- GLQL relies on
crypto.subtle, which is unavailable in insecure contexts (except forlocalhost), it won’t work if you're using a custom URL likehttp://gdk.test:3000locally. To resolve this, one of the options is to enable HTTPS in GDK by following this link. - Enable the following feature flags in
rails c:
=> Feature.enable(:glql_integration)
=> Feature.enable(:glql_work_items)
=> Feature.enable(:glql_es_integration)
- Navigate to any issue comment or description field where Markdown is supported
- Add the following GLQL query into the field:
```glql
display: table
fields: title, labels, health
query: group = "gitlab-org" and health = "on track"
```
- Test with different
healthfield variations provided above in the MR description section.
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 #540813 (closed)
Edited by Alisa Frunza