Skip to main content

Paginating Results

Shaped handles the pagination of results for you. We handle it by adding all served item ids to a 'pagination store' and then filtering out these items from the candidate item set of subsequent requests.

Pagination Store TTL Configuration

Items added to the pagination store expire based on a configurable time-to-live (TTL) that defaults to 3600 seconds (1 hour). However, you can configure this within the model creation configuration definition. A value of 0 will disable the pagination store entirely, for example, if you'd prefer to handle pagination yourself.

$ cat create_model.yaml

model:
name: your-model-name
pagination_store_ttl: 600 # (10 minutes)
connectors:
- type: Dataset
id: your-file-connector
name: your-file-connector
fetch:
events: |
SELECT user_id, item_id, label, created_at
FROM your-file-connector

Pagination Store Rank Configurations

There are two pagination store configurations that can be set at rank time:

  1. Flush Paginations: This allows you to clear the pagination store for the given user at the start of the request. This is useful for use-cases, such as when a user refreshes the page and would like to see the start of the ranked results again.
  2. Ignore Paginations: This allows you to ignore the pagination filter step completely, it can be helpful if you're debugging results for an end user, but don't want to affect their pagination state.

Take a look at the Rank API documentation for more information on how to use these arguments.