SearchAfter API (V1)
The SearchAfter API is used to fetch multiple pages of search results sequentially. To start, a request is made for the first page of results, which includes a last_hit_data
value corresponding to the last item in the page. This value is then used to fetch subsequent pages until all results are retrieved.
Not all search results are kept in memory. To have consistent search results between pages, add at least one query parameter that is unique and easily sortable, for example, an identifier. Using a modification date might return inconsistent results if new entities are modified while navigating between pages in the same search result set.
This resource is available at the following URL:
GET http://<HOSTNAME>/api/entities/searchafter/
SearchAfter API can have the following query strings:
String |
Description |
---|---|
|
Sorting type, with two different inputs:
|
|
Ordering of results. |
|
For a given set of results when making a request after the first one, provide the preceding value of |
|
A normal query. |
|
Number of items to fetch per page. The default is 25, and the maximum is 100. |
|
Members to be retrieved. |
|
Renditions to be retrieved. |
|
User culture, for example |
|
If no culture is specified, it uses the invariant culture by default. |
Example
The following example shows the initial request made to fetch a list of assets, sorted in ascending order by creation date:
/api/entities/searchafter?query=Definition.Name=="M.Asset"&sort=createdOn&order=Asc
The results include the first 25 items in a set of 212. The value of last_hit_data
here corresponds with the 25th item:
{
"last_hit_data": [
"1680149774978"
],
"items": [],
"total_items": 212,
"returned_items": 25
}
By adding the value of last_hit_data
to a subsequent request based on the same criteria, you can fetch the next 25 items in the set, beginning with the 26th.
/api/entities/searchafter?query=Definition.Name=="M.Asset"&sort=createdOn&order=Asc&searchAfter=1678176769452