diff --git a/src/Engines/MeilisearchEngine.php b/src/Engines/MeilisearchEngine.php index d3c3420..abf79a5 100644 --- a/src/Engines/MeilisearchEngine.php +++ b/src/Engines/MeilisearchEngine.php @@ -195,7 +195,7 @@ public function map(Builder $builder, $results, $model) */ public function getTotalCount($results) { - return $results['nbHits']; + return count($results['hits']); } /** diff --git a/tests/MeilisearchEngineTest.php b/tests/MeilisearchEngineTest.php index ae4dcb9..2787adc 100644 --- a/tests/MeilisearchEngineTest.php +++ b/tests/MeilisearchEngineTest.php @@ -69,7 +69,7 @@ public function mapIdsReturnsEmptyCollectionIfNoHits() $engine = new MeilisearchEngine($client); $results = $engine->mapIds([ - 'nbHits' => 0, 'hits' => [], + 'hits' => [], ]); $this->assertEquals(0, count($results)); @@ -87,7 +87,7 @@ public function mapCorrectlyMapsResultsToModels() $builder = m::mock(Builder::class); $results = $engine->map($builder, [ - 'nbHits' => 1, 'hits' => [ + 'hits' => [ ['id' => 1], ], ], $model); @@ -113,7 +113,7 @@ public function mapMethodRespectsOrder() $builder = m::mock(Builder::class); $results = $engine->map($builder, [ - 'nbHits' => 4, 'hits' => [ + 'hits' => [ ['id' => 1], ['id' => 2], ['id' => 4],