Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined index: docScores #278

Open
AntonioBSousa opened this issue Jan 27, 2023 · 2 comments
Open

Undefined index: docScores #278

AntonioBSousa opened this issue Jan 27, 2023 · 2 comments

Comments

@AntonioBSousa
Copy link

I installed TntSearch by Scout to be able to find records by string. The problem is when i use search()->get() method on my controller and receive "message": "Undefined index: docScores" error, but when i use search()->raw() i receive the corrects matchs ids.

Trying to understand the problem, i discovered that the possible problem is on: laravel-scout-tntsearch-driver\src\Engines\TNTSearchEngine.php" inside of return $model->newCollection(collect($results['ids'])->map(function ($hit) use ($models, $results) {
if (isset($models[$hit])) {
return $models[$hit]->setAttribute('tntSearchScore', $results['docScores'][$hit]);
}
})->filter()->all());

Where the laravel dont recognize in $results['docScores'][$hit]) the 'DocScore.

@hayaku-fr
Copy link

hayaku-fr commented Feb 21, 2023

Same here,
setting searchBoolean to false solves the problem.
Below are return of TNTSearch for search and searchBoolean :

return [
'ids' => array_keys($docs->toArray()),
'hits' => $totalHits,
'docScores' => $docScores,
'execution_time' => round($stopTimer - $startTimer, 7) * 1000 ." ms"
];

return [
'ids' => $docs->toArray(),
'hits' => $docs->count(),
'execution_time' => round($stopTimer - $startTimer, 7) * 1000 ." ms"
];

@tomrlh
Copy link

tomrlh commented Jun 15, 2023

Thank you @hayaku-fr , ChatGPT didn't know to solve this issue haha

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants