Skip to content

Commit

Permalink
perf(typesense): skip collection check for search operations (#898)
Browse files Browse the repository at this point in the history
* fix(typesense): skip collection check for search operations

- Add early return for search operations in `getOrCreateCollectionFromModel`
- Maintain collection existence check only when `indexOperation` is true
- Optimize search performance by reducing unnecessary API calls

* lint
  • Loading branch information
tharropoulos authored Dec 18, 2024
1 parent 480adfa commit 2fe33e6
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Engines/TypesenseEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ protected function getOrCreateCollectionFromModel($model, bool $indexOperation =
$collectionName = $model->{$method}();
$collection = $this->typesense->getCollections()->{$collectionName};

if (! $indexOperation) {
return $collection;
}

// Determine if the collection exists in Typesense...
try {
$collection->retrieve();
Expand Down

0 comments on commit 2fe33e6

Please sign in to comment.