🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API Reference / API Parameters / offset
Type: integer
Engine default: null (no offset)
Parameter syntax
'offset' => record_number

Can be used in these methods:

About this parameter

Determine the position of a particular record in the dataset.

In most cases, page and hitsPerPage is the recommended method for pagination. This setting is part of an alternative paging approach.

Usage notes

Offset is the position in the dataset of a particular record. By specifying offset, you retrieve a subset of records tarting with the offset value.

Offset is zero-based: the 10th record is at offset 9.

Use it in combination with length, to retrieve a subset of records. For example, if you have 100 records in your results, and want to retrieve records 50 to 80, use offset=49 and length = 30.

  • If offset is omitted, length is ignored.
  • If offset is specified but length omitted, the number of records returned is equal to hitsPerPage. Using offset requires that you specify length as well; otherwise, it defaults to page-based pagination.

Impact on the response:

  • Page-based pagination (page / hitsPerPage):

    1
    2
    3
    4
    5
    6
    7
    
    {
      ...
      "page": 1,
      "nbPages": 20,
      "hitsPerPage": 10,
      ...
    }
    
  • With offset / length:

    1
    2
    3
    4
    5
    6
    
     {
       ...
       "offset": 5,
       "length": 10,
       ...
     }
    

Examples

Get results starting at the nth hit

1
2
3
$results = $index->search('query', [
  'offset' => 4
]);
Did you find this page helpful?