You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Getting no results on Laravel 8 and Sphinx 2.2
Problem in src/SphinxEngine.php
public function map(Builder $builder, $results, $model)
{
if ($results->count() === 0) {
return $model->newCollection();
}
$objectIds = collect($results->fetchAllAssoc())->pluck('id')->values()->all();
$objectIdPositions = array_flip($objectIds);
return $model->getScoutModelsByIds(
$builder, $objectIds
)->filter(static function (/** @var Searchable $model */ $model) use ($objectIds) {
return in_array($model->getScoutKey(), $objectIds, true);
})->sortBy(static function (/** @var Searchable $model */ $model) use ($objectIdPositions) {
return $objectIdPositions[$model->getScoutKey()];
})->values();
}
$objectIds = collect($results->fetchAllAssoc())->pluck('id')->values()->all(); - return an array of Strings
in_array($model->getScoutKey(), $objectIds, true); - here requires Strict in_array, id - integer, objectIds - Strings
As a solution -
public function getScoutKey()
{
return (string) $this->id;
}
But it is not goes outofthebox
The text was updated successfully, but these errors were encountered:
Getting no results on Laravel 8 and Sphinx 2.2
Problem in src/SphinxEngine.php
public function map(Builder $builder, $results, $model)
{
if ($results->count() === 0) {
return $model->newCollection();
}
$objectIds = collect($results->fetchAllAssoc())->pluck('id')->values()->all(); - return an array of Strings
in_array($model->getScoutKey(), $objectIds, true); - here requires Strict in_array, id - integer, objectIds - Strings
As a solution -
public function getScoutKey()
{
return (string) $this->id;
}
But it is not goes outofthebox
The text was updated successfully, but these errors were encountered: