Paging through Results
The /edsapi/rest/search results are paginated. The pagenumber parameter specifies the page number of the records returned. The resultsperpage parameter indicates the number of records to return for a request.
In order to optimize system performance, there is a limit on the pagenumber parameter value when using the /edsapi/rest/search endpoint to jump over records. The maximum number that can be used for the pagenumber parameter is a sliding limit when jumping over records, not a hard limit. The sliding limit is based on the last requested record within the current search of the session. You can traverse the entire result set. If you request beyond the limit, you will receive the Max Record Retrieval Exceeded error, error code 138.
To Determine the Maximum Page Number that Can Be Requested with the /edsapi/rest/search Endpoint (example):
-
Call the /edsapi/rest/info endpoint.
-
Examine the response for the ApiSettings element.
"ApiSettings": { "MaxRecordJumpAhead":"250" }
<ApiSettings> <MaxRecordJumpAhead>250</MaxRecordJumpAhead> </ApiSettings>
The MaxRecordJumpAhead is the maximum number of records that you can jump over in one search.
-
Determine the last requested page. In this example, the last requested page is 1.
-
Determine the results per page. In this example, the results per page is 10. Since the last requested page is 1, records 1-10 were already requested. The maximum record already requested is 10.
-
Add the MaxRecordJumpAhead to the maximum record already requested. This determines the last record skipped if you skip the maximum allowed. In this example, the last record skipped for the maximum allowed is 10 + 250 = 260.
-
Determine the last page skipped if requesting the maximum number of records allowed. Divide the result of step 5 by the number of records in a page. In this example, 260/10 = 26.
-
Determine the max page number that can be requested by adding 1 to the last page skipped. In this example, 26 + 1 = 27. Therefore, the maximum page number that can be requested without exceeding the limit is 27. In this example, if you request a page greater than 27, you will receive the Max Record Retrieval Exceeded error.
You can continue iterating through the results based on your last requested page as you advance. Keep in mind that paging backward through results will lower the last record position retrieved. The limit will be based on your last record position regardless of whether you went forward and then back.
Common Issues
Improper use of the session will cause the sliding calculation to fail. The following EDS API anti-patterns will yield undesired results.
- Generating a new session with every request. Please, do not do this. If every request to page through a search is preceded by creating a new session, then the last record position is lost. The last record position is not carried from one session to the next. Therefore, a user will not be able to reach the end of a result set. This will give the impression that the maximum jump ahead is a hard limit.
- Sharing sessions across users. Please, do not do this. When sessions are shared among users, paging activity will be overwritten. This is because sharing a session forces the last record position to be shared. This will yield wildly inconsistent behavior. One user’s max record jump calculation will be based on another user’s search activity.
As long as you implement the client properly, you can access records beyond the MaxRecordJumpAhead value without receiving the Max Record Retrieval Exceeded error.
Updated 9 days ago