Incorrect pageInfo.hasNextPage with RELEVANCE sortKey in Products Query

When querying products with sortKey: RELEVANCE, the pageInfo.hasNextPage is incorrectly returning false even when there are more results available. However, when using other sort keys (like TITLE), pagination works as expected.

Example

Here are two identical queries, only differing in their sortKey:

With sortKey: RELEVANCE:

graphql
query {
products(first: 10, reverse: true,
query: "(title:'Marshall Plan' OR title:'Marshall' OR title:'Plan') AND OR (sku:'Marshall Plan')",
sortKey: RELEVANCE
) {
edges { ... }
pageInfo {
hasNextPage
hasPreviousPage
endCursor
startCursor
}
}
productsCount(query: "(title:'Marshall Plan' OR title:'Marshall' OR title:'Plan') AND OR (sku:'Marshall Plan')") {
count
}
}

Response:

json
{
"pageInfo": {
"hasNextPage": false,
"hasPreviousPage": false
},
"productsCount": {
"count": 38
}
}

Response with sortKey: TITLE instead of RELEVANCE:

json
{
"pageInfo": {
"hasNextPage": true,
"hasPreviousPage": false
},
"productsCount": {
"count": 38
}
}

Since we’re requesting 10 items (first: 10) and there are 38 total results, hasNextPage should be true regardless of the sortKey used.

  1. Is this a known issue with the RELEVANCE sort key?
  2. Is there a workaround to get correct pagination information when using RELEVANCE sorting?
  3. Should we avoid using RELEVANCE sorting when implementing pagination?

Any insights would be greatly appreciated!

Hey Charles,

Have flagged this to our developer support team - will update here when I hear back.

Hi again Charles,

Where exactly are you using this query? Is this in the search and discovery app?

The queries are executed from a custom embedded Node.js app using the @shopify/shopify-api package through a GraphQL client.

If you test this in the GraphiQL app, are you seeing the same issue?