offset
null (no offset)
'offset' => record_number
Can be used in these methods:
search,
browseObjects,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
browse,
generate_secured_api_key,
add_api_key,
update_api_key
search,
browse,
generateSecuredApiKey,
addApiKey,
updateApiKey
search,
browse_objects,
generate_secured_api_key,
add_api_key,
update_api_key
search,
browse
search,
browseObjects,
generateSecuredApiKey,
addApiKey,
updateApiKey
searchAsync,
browseAsync
Search,
Browse,
GenerateSecuredApiKey,
AddApiKey,
UpdateApiKey
Search,
browse,
generateSecuredApiKey,
addApiKey,
updateApiKey
Search,
BrowseObjects,
GenerateSecuredAPIKey,
AddAPIKey,
UpdateAPIKey
search,
browse index,
generateSecuredApiKey,
add key,
update key
About this parameter
Specify the offset of the first hit to return.
In most cases, page/hitsPerPage is the recommended method for pagination. This setting is part of an alternative paging approach.
Offset is the position in the dataset of a particular record.
By specifying offset, you retrieve a subset of records
starting with the offset value.
Offset normally works with length,
which determines how many records to retrieve starting from the offset.
Usage notes:
-
Offset is zero-based: the 10th record is at offset 9.
-
If you omit
length, the number of records returned is equal to thehitsPerPage. In fact, usingoffsetrequires that you specifylengthas well; otherwise, it defaults to page-based pagination. -
If
offsetis specified,pageis ignored. -
Usage: If you have 100 records in your result set, and you want to retrieve records 50 to 80, you will need to use
offset=49andlength = 30.
Impact on the response:
-
Page-based pagination (page / hitsPerPage):
Copy1 2 3 4 5 6 7
{ ... "page": 1, "nbPages": 20, "hitsPerPage": 10, ... }
-
With offset / length:
Copy1 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
]);