如何使用PHP增加Algolia的命中?
如何使用阿尔戈利亚获得更多的1000结果。此功能仅返回1000个结果。我使用$ CurrentPage ++增加了页码。但是在返回1000个结果后,当阿尔戈利亚有9000多个记录时,将显示0个结果。我已经用PHP编写了此代码,找不到可能的解决方案。
function getAlgoliaResults($index, $query, $userid, $ipaddress)
{
global $ObjectidsArray;
$currentpage = 0;
$objects = null;
$idarray = array();
do {
$objects = $index->search($query, [
'hitsPerPage' => 1000,
'page' => $currentpage,
'offset' => 0,
'length' => 1000,
'X-Forwarded-For' => $ipaddress,
'userToken' => $userid
]);
foreach ($objects['hits'] as $rec) {
$ObjectidsArray[$rec['id']] = $rec['objectID'];
array_push($idarray, $rec['id']);
}
if (count($objects['hits']) <= 1000){
$currentpage++;
}
} while (count($objects['hits']) > 0);
return $idarray;
}
How can I get more then 1000 result using algolia. This function is only returning 1000 results. I have increase the page number using $currentpage++. But after returning 1000 results it is showing 0 result when there is 9000+ records in Algolia. I have written this code in php and couldn't find the possible solutions.
function getAlgoliaResults($index, $query, $userid, $ipaddress)
{
global $ObjectidsArray;
$currentpage = 0;
$objects = null;
$idarray = array();
do {
$objects = $index->search($query, [
'hitsPerPage' => 1000,
'page' => $currentpage,
'offset' => 0,
'length' => 1000,
'X-Forwarded-For' => $ipaddress,
'userToken' => $userid
]);
foreach ($objects['hits'] as $rec) {
$ObjectidsArray[$rec['id']] = $rec['objectID'];
array_push($idarray, $rec['id']);
}
if (count($objects['hits']) <= 1000){
$currentpage++;
}
} while (count($objects['hits']) > 0);
return $idarray;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论