diff --git a/src/Meilisearch/Index.php b/src/Meilisearch/Index.php index 0371ba5..869611f 100644 --- a/src/Meilisearch/Index.php +++ b/src/Meilisearch/Index.php @@ -108,7 +108,7 @@ public function update() return $this; } - public function searchUsingApi($query, $options = ['hitsPerPage' => 1000000]) + public function searchUsingApi($query, $options = ['hitsPerPage' => 1000000, 'showRankingScore' => true]) { try { $searchResults = $this->getIndex()->search($query, $options); @@ -116,7 +116,12 @@ public function searchUsingApi($query, $options = ['hitsPerPage' => 1000000]) $this->handlemeilisearchException($e, 'searchUsingApi'); } - return collect($searchResults->getHits()); + collect($searchResults->getHits())->map(function ($hit) { + $hit['search_score'] = (int) ceil($hit['_rankingScore'] * 1000); + unset($hit['_rankingScore']); + + return $hit; + }); } private function getIndex()