length
null
(no offset)
'length' => number_of_records
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
Set the number of hits to retrieve (used only with offset).
In most cases, page/hitsPerPage is the recommended method for pagination. This setting is part of an alternative paging approach.
Similar to hitsPerPage, but works only with offset.
Usage notes:
-
1000 is the maximum.
-
If
offset
is omitted,length
is ignored. -
On the other hand, if you specify
offset
but omitlength
, the number of records returned is equal to thehitsPerPage
. In fact, usingoffset
requires that you specifylength
as well; otherwise, it defaults to page-based pagination.
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 n results
1
2
3
$results = $index->search('query', [
'length' => 4
]);