Pagination not working when querying related content by Rest API
Describe the bug When using the Content API with /related, /limit, and /offset path. Changing the offset parameter does not do anything. As a result Content API always returns the same contentlets.
Related Ticket: https://dotcms.zendesk.com/agent/tickets/107332
Reproduced on: 22.03
To Reproduce Steps to reproduce the behavior:
- Go to
http://demo.dotcms.com/api/content/render/false/query/+contentType:Destination%20+languageId:1%20+deleted:false%20+working:true/orderby/score,modDate%20desc/related/Destination.activities:574f0aec-185a-4160-9c17-6d037b298318/limit/1/offset/0. - Go to
http://demo.dotcms.com/api/content/render/false/query/+contentType:Destination%20+languageId:1%20+deleted:false%20+working:true/orderby/score,modDate%20desc/related/Destination.activities:574f0aec-185a-4160-9c17-6d037b298318/limit/1/offset/1. - Verify the results of both api's After changing the offset result is still the same.
Expected behavior In Content API when we use /related /limit /offset. After changing the offset next page result should appear.
They should use the POST methods as the get/url param methods are deprecated. These seem to work:
curl -XPOST 'https://demo.dotcms.com/api/content/_search' \
-H 'Content-Type: application/json' \
-d '{
"query": "+contentType:Destination +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST) +languageId:1 +deleted:false +working:true",
"sort": "score,modDate desc",
"limit": 1,
"offset": 1
}'
curl -XPOST 'https://demo.dotcms.com/api/content/_search' \
-H 'Content-Type: application/json' \
-d '{
"query": "+contentType:Destination +(conhost:48190c8c-42c4-46af-8d1a-0cd5db894797 conhost:SYSTEM_HOST) +languageId:1 +deleted:false +working:true",
"sort": "score,modDate desc",
"limit": 1,
"offset": 2
}'
Actually, looking a the above, those are not apples to apples queries. I don't know if we offer the related parameter in the post method. More discovery is needed.
PR: https://github.com/dotCMS/core/pull/22738
Fixed, tested on release-22.09 // Docker // FF