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.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,626 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 34,821 Reputation points Microsoft Vendor
    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 Answers by the question author, which helps users to know the answer solved the author's problem.