SearchAfter API 1.0

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.

Important

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:

RequestResponse
// [!code word:<HOSTNAME>] 

GET http://<HOSTNAME>/api/entities/searchafter/

SearchAfter API can have the following query strings:

String

Description

sort

Sorting type, with two different inputs:

  • Name of an item based on which you want to sort the results, for example sort=CreatedOn&order=Asc.

  • A sort and order combination, for example sort=CreatedOn+Asc,Importance+Desc.

order

Ordering of results.

searchAfter

For a given set of results when making a request after the first one, provide the preceding value of last_hit_data here.

query

A normal query.

take

Number of items to fetch per page. The default is 25, and the maximum is 100.

members

Members to be retrieved.

renditions

Renditions to be retrieved.

culture

User culture, for example en-us.

sortCulture

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:

RequestResponse

/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:

RequestResponse

  {
    "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.

RequestResponse

/api/entities/searchafter?query=Definition.Name=="M.Asset"&sort=createdOn&order=Asc&searchAfter=1678176769452

Do you have some feedback for us?

If you have suggestions for improving this article,