TypesenseBundle
TypesenseBundle copied to clipboard
Hotfix: load the client if collection array is empty and allow to use everything dynamically
- load the client if collection array is empty and allow to use everything dynamically
Hello @EfrosIonelu by curiosity, why would you need to load the config if no collections are defined ?
Hi, sure, there is my example: I added current library but i do not have any entity to typesense collection representation, Instead i need to migrate to typesense dynamic collections that do not have model representation,
The idea is to have access to TypesenseClient, if there are not collection and add collection definition dynamically
...
public function __construct(
private readonly TypesenseClient $typesenseClient,
...
if ($this->typesenseClient->getCollections()['example']->exists()) {
$this->typesenseClient->getCollections()['example']->delete();
}
....
$this->typesenseClient->getCollections()->create([
'name' => 'example',
'enable_nested_fields' => true,
'fields' => [
....
]
....
$this->typesenseClient->getCollections()['example']->documents->upsert($data);
....