GLQL pagination returns empty results after first page when using Advanced Search
Summary
When using GLQL with Advanced Search (Elasticsearch) enabled, pagination fails to return results beyond the first page. Clicking "Load more" returns an empty result set even when more matching items exist.
- Context: https://gitlab.slack.com/archives/C07HUEF4VPD/p1765236721800119 (Internal)
Steps to reproduce
- Enable Advanced Search (Elasticsearch) integration
- Create a project with multiple work items (more than the page limit)
- Ensure work items have sortable field values that span multiple pages
- Navigate to the project's work items page
- Execute a GLQL query with sorting and a small page limit:
display: table fields: title, milestone limit: 3 query: project = "your-project" AND type = issue sort: created_at asc - Wait for the first page to load (should show first 3 items)
- Click the "Load more" button to fetch the next page
What is the current bug behavior?
When clicking "Load more":
- An empty result set is returned (
nodes: []) -
hasNextPageisfalse -
countis0 - No additional items are loaded
The GraphQL request is sent with the correct after cursor parameter, and the Elasticsearch query is generated with pagination filters, but no results match the filter criteria.
What is the expected correct behavior?
Clicking "Load more" should:
- Use the cursor from the previous page to fetch the next set of results
- Return the next page of items that match the query
- Continue until all matching items have been retrieved
- Allow users to paginate through all available results
Example
Test scenario:
- Project with 10 work items (IDs 1-10)
- GLQL query with
limit: 3andsort: created_at asc
Expected:
- Page 1: Items 1, 2, 3
- Page 2 (after "Load more"): Items 4, 5, 6
- Page 3 (after "Load more"): Items 7, 8, 9
- Page 4 (after "Load more"): Item 10
Actual:
- Page 1: Items 1, 2, 3
- Page 2 (after "Load more"): Empty (0 items)
Additional context
- The issue only occurs with Advanced Search (Elasticsearch) integration
- Database-only work item queries work correctly
- The GraphQL API correctly returns
hasNextPage: trueon the first page - The cursor value is correctly encoded and sent in the second request
- Elasticsearch queries show pagination filters are being applied
Environment
- GitLab version: 18.7.0-pre (likely affects earlier versions)
- Feature flags:
glql_es_integrationenabled - Advanced Search: Enabled with Elasticsearch
Related
This issue was discovered while testing GLQL functionality with Advanced Search integration.
Edited by Dmitry Gruzd