Skip to content

Commit d16e56a

Browse files
committed
Pagation approach for large result sets
added new article explaining the new approach. updated the existing doc about startrow limit.
1 parent 6bf171d commit d16e56a

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: Pagination for large result sets
3+
ms.date: 10/14/2020
4+
ms.prod: sharepoint
5+
localization_priority: Priority
6+
---
7+
8+
# Pagination for large result sets
9+
10+
If you have a large number of pages (for example, over 50,000) to page through in a query, it is recommended to use the approach explained in this article instead of the approach of [StartRow](https://docs.microsoft.com/sharepoint/dev/general-development/sharepoint-search-rest-api-overview#startrow). This approach uses sorting on `[docid]` in ascending order and uses a query restriction on the `IndexDocId` value with an increasing value of `IndexDocID` for each new page.
11+
12+
The advantages of this approach are:
13+
14+
- It provides pagination with better performance
15+
- It does not have a limit on the number of pages
16+
17+
Here is an example of using this approach:
18+
19+
For Page 1, issue a query with sort on `[docid]` in ascending order:
20+
21+
```http
22+
GET http:// _server_/_api/search/query?querytext='sharepoint'&sortlist='[docid]:ascending'
23+
```
24+
25+
The result of this query should contain the following content:
26+
27+
```xml
28+
...
29+
<d:element m:type="SP.SimpleDataRow">
30+
<d:Cells>
31+
...
32+
<d:element m:type="SP.KeyValue">
33+
<d:Key>DocId</d:Key>
34+
<d:Value>10</d:Value>
35+
<d:ValueType>Edm.Int64</d:ValueType>
36+
</d:element>
37+
...
38+
```
39+
40+
Get the `DocId` value of the last entry in the result. You should be able to find `DocId` under `SP.SimpleDataRow`. Let's say the `DocId` value is `10`. We will use that as the `DocID` restriction for page 2:
41+
42+
For Page 2, we use the following query, where we continue using sortlist on `DocId` in ascending order, but also add an `IndexDocId` restriction:
43+
44+
```http
45+
GET http:// _server_/_api/search/query?querytext='sharepoint indexdocid>10'&amp;sortlist='[docid]:ascending'
46+
```
47+
48+
Let's say the `DocId` value of the last entry in the result is 20.
49+
50+
For Page 3, we continue the query with the same pattern as previous page:
51+
52+
```http
53+
GET http:// _server_/_api/search/query?querytext='sharepoint indexdocid>20'&amp;sortlist='[docid]:ascending'
54+
```
55+
56+
And so on for the rest of the pages.

docs/general-development/sharepoint-search-rest-api-overview.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,9 @@ GET http:// _server_/_api/search/query?querytext='sharepoint'&amp;startrow=10
239239
}
240240
```
241241

242+
> [!NOTE]
243+
> Please be aware that in order to provide search experience with high performance, we limit the maximum supported value of `StartRow` to be **50,000**. If you need to page through larger result sets, please see [Pagination for large result sets.](https://docs.microsoft.com/sharepoint/dev/general-development/pagination-for-large-result-sets)
244+
242245
<a name="bk_RowLimit"> </a>
243246

244247
### RowLimit

docs/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,8 @@
10981098
items:
10991099
- name: Retrieve query suggestions using the Search REST service
11001100
href: general-development/retrieving-query-suggestions-using-the-search-rest-service.md
1101+
- name: Pagination for large result sets
1102+
href: general-development/pagination-for-large-result-sets.md
11011103
- name: Search add-ins
11021104
href: general-development/search-add-ins-in-sharepoint.md
11031105
- name: Customize search results

0 commit comments

Comments
 (0)