Skip to content

Commit

Permalink
Fixing issue 825 (#826)
Browse files Browse the repository at this point in the history
* - Prevent unnecessary api calls on Collection (index).

* - style fix.

* - Added Typesense searchable test case.

* - Updated typesense-php version in composer.
- Fix issue that causes collection to be recreated.

* - Fix typesense-php version.

* Update TypesenseEngine.php

Fix variable name.
  • Loading branch information
AbdullahFaqeir authored May 6, 2024
1 parent e8fa704 commit 8146bf4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
10 changes: 6 additions & 4 deletions src/Engines/TypesenseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') ?? [];
Expand All @@ -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;
}

/**
Expand Down

0 comments on commit 8146bf4

Please sign in to comment.