Skip to content

Commit 58e8cd5

Browse files
authored
Pagination approach for large result sets (SharePoint#6391)
* Pagination approach for large result sets added new article explaining the new approach. updated the existing doc about startrow limit. * update on url reference and links fixed URL reference replaced absolute links with relative links
1 parent c828864 commit 58e8cd5

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 search results (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](./sharepoint-search-rest-api-overview.md#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 (if you use the approach of [StartRow](./sharepoint-search-rest-api-overview.md#startrow) and the `StartRow` value is greater than 50,000, there is a risk of being throttled by SharePoint)
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://{site_url}/_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`. You will use that as the `DocID` restriction for page 2:
41+
42+
For Page 2, use the following query, where you need to continue using sortlist on `DocId` in ascending order, but also add an `IndexDocId` restriction:
43+
44+
```http
45+
GET http://{site_url}/_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, continue the query with the same pattern as previous page:
51+
52+
```http
53+
GET http://{site_url}/_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.](./pagination-for-large-result-sets.md)
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
@@ -1100,6 +1100,8 @@
11001100
items:
11011101
- name: Retrieve query suggestions using the Search REST service
11021102
href: general-development/retrieving-query-suggestions-using-the-search-rest-service.md
1103+
- name: Pagination for large result sets
1104+
href: general-development/pagination-for-large-result-sets.md
11031105
- name: Search add-ins
11041106
href: general-development/search-add-ins-in-sharepoint.md
11051107
- name: Customize search results

0 commit comments

Comments
 (0)