diff --git a/composer.json b/composer.json index 04555181..7b59fed4 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ }, "require-dev": { "algolia/algoliasearch-client-php": "^3.2", - "typesense/typesense-php": "^4.9.2", + "typesense/typesense-php": "^4.9.3", "meilisearch/meilisearch-php": "^1.0", "mockery/mockery": "^1.0", "orchestra/testbench": "^7.31|^8.11|^9.0", diff --git a/src/Engines/TypesenseEngine.php b/src/Engines/TypesenseEngine.php index fd12b076..b55622a5 100644 --- a/src/Engines/TypesenseEngine.php +++ b/src/Engines/TypesenseEngine.php @@ -496,10 +496,10 @@ public function deleteIndex($name) */ protected function getOrCreateCollectionFromModel($model): TypesenseCollection { - $index = $this->typesense->getCollections()->{$model->searchableAs()}; + $collection = $this->typesense->getCollections()->{$model->searchableAs()}; - if ($index->exists() === true) { - return $index; + if ($collection->exists() === true) { + return $collection; } $schema = config('scout.typesense.model-settings.'.get_class($model).'.collection-schema') ?? []; @@ -514,7 +514,9 @@ protected function getOrCreateCollectionFromModel($model): TypesenseCollection $this->typesense->getCollections()->create($schema); - return $this->typesense->getCollections()->{$model->searchableAs()}; + $collection->setExists(true); + + return $collection; } /**