Open
Description
## Description
<!--- Describe the issue here -->
Im trying to integrate typesense in my symfony application for that i have written below code
TypesenseService.php
<?php
namespace App\Service;
use Typesense\Client;
class TypesenseService
{
private $typesenseClient;
public function __construct()
{
$this->typesenseClient = new Client([
'api_key' => 'exceloid-test',
'nodes' => [
[
'host' => '95.216.171.30',
'port' => '8092',
'protocol' => 'http',
],
],
'connection_timeout_seconds' => 2,
]);
}
public function getTypesenseClient(): Client
{
return $this->typesenseClient;
}
}
Productservice.php
<?php
namespace App\Service;
use Psr\Log\LoggerInterface;
class ProductService
{
private $typesenseService;
private $logger;
public function __construct(TypesenseService $typesenseService, LoggerInterface $logger)
{
$this->typesenseService = $typesenseService;
$this->logger = $logger;
}
public function getProducts(): array
{
$typesenseClient = $this->typesenseService->getTypesenseClient();
$searchParameters = [
'q' => 'banana',
'query_by' => 'shortName'
];
$searchResults = $typesenseClient->collections['Ofcproducts']->documents->search($searchParameters);
$products = [];
foreach ($searchResults['hits'] as $hit) {
$document = $hit['document'];
unset($document['document']);
$products[] = $document;
}
return $products;
// return $searchResults['hits'];
}
}
and when im trying to call this function in any controller
$typesenseProducts = $this->productService->getProducts();
im getting below error
Uncaught PHP Exception JsonException: "Syntax error" at /home/exceloid/OFC-ECOM/organic-api/vendor/typesense/typesense-php/src/ApiCall.php line 236
till 3 dec 2023 it was working fine ,but now getting syntax error from library
an someone pls help me
**Typesense Version**:4.8 or 4.9
**OS**: ubuntu
Metadata
Assignees
Labels
No labels