Pagination in large dataset Search API SharePoint online

Vaishali Vyas 1 Reputation point
2022-02-15T10:37:07.36+00:00

Hi,

I am using SharePoint Search API to get the items from SharePoint List.
We have large dataset. So I am following below approach for pagination.

https://learn.microsoft.com/en-us/sharepoint/dev/general-development/pagination-for-large-result-sets

In this I am sorting based on DocId.

But we also have to sort based on the created on Date, I am using below API.

API:
https://site/_api/search/query?querytext='test ListId:0ae14d29'&trimduplicates=false&selectproperties='Title,Subject,
CreatedOn,Direction,RegardingId,RegardingTableName,RegardingObjectName,Path,DocId,StatusReason'&sortlist='refinabledate00:descending,[docid]:ascending'&rowlimit=10

but when I try to get results for page 2 it is not giving me the correct result. It gives the same set of records as on page 1.

If I retrieve records without createdOn sorting I am getting correct records but we want sorting based on date as well.

Microsoft 365 and Office | SharePoint | For business | Windows
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,486 Reputation points Microsoft External Staff
    2022-02-16T09:17:52.807+00:00

    Hi @Vaishali Vyas ,
    For page 2, You should refer to following url. You need to continue using sortlist on DocId in ascending order, but also add an IndexDocId restriction.

    http://{site_url}/_api/search/query?querytext='sharepoint indexdocid>10'&sortlist='[docid]:ascending'  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.