GLQL query returns incorrect results when using Elasticsearch vs database
Summary
GLQL queries with label filters return different (incorrect) results when using Elasticsearch compared to direct database queries. A specific query for Plan Stage Roadmap epics returns only 1 result via ES but 10 results when bypassing ES with ?useES=false
.
Note
To reproduce it on .com, you need to enable the glql_es_integration
FF for your user via chatops
Steps to reproduce
- Create a GLQL query with label filters:
```glql
display: table
title: Plan Stage Roadmap
fields: labels("group::*") as "Group", due, title, state, milestone, assignees
query: group = "gitlab-org" AND type = Epic AND label = ~"devops::plan" and label = ~"Plan Roadmap"
```
- Embed this query in a wiki page or issue note
- View the results (should show only 2 epics)
- Add
?useES=false
parameter to the page URL - Compare results (should now show 11 epics)
What is the current bug behavior?
- GLQL query returns only 1 epics when using Elasticsearch
- The same query returns 10 epics when bypassing Elasticsearch (
?useES=false
) - Regular issue listing pages show the correct 10 results
What is the expected correct behavior?
- GLQL query should return the same results whether using Elasticsearch or database queries
- Both should return 10 epics matching the specified criteria
- Results should be consistent with regular GitLab issue/epic listing functionality
Relevant logs and/or screenshots
Test URLs demonstrating the issue:
- With ES (shows 1 results): https://gitlab.com/gitlab-org/plan-stage/test-project/-/issues/265
- Without ES (shows 10 results): https://gitlab.com/gitlab-org/plan-stage/test-project/-/issues/265?useES=false
Possible fixes
The issue likely lies in one of these areas:
- GLQL to Elasticsearch query translation, particularly for label matching syntax (
~"label"
) - Label field mapping or analyzer configuration in Elasticsearch
- Boolean logic interpretation differences between ES and database queries
- Case sensitivity or special character handling in label searches
Investigation should focus on comparing the actual ES query generated vs the database query for the same GLQL input.
Edited by Dmitry Gruzd