Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Here are some examples that walk you through how to use the client: [doc/example

| Typesense Server | typesense-php |
|------------------|----------------|
| \>= v0.16.0 | \>= v4.2.0 |
| \>= v0.16.0 | \>= v4.1.0 |
| \>= v0.15.0 | \>= v4.0.0 |

Expand Down
6 changes: 5 additions & 1 deletion examples/collection_operations.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
echo "--------Delete Document-------\n";
echo "\n";
echo "--------Import Documents-------\n";
$docsToImport = [];
$docsToImport = [];
$exportedDocStrsArray = explode('\n', $exportedDocStrs);
foreach ($exportedDocStrsArray as $exportedDocStr) {
$docsToImport[] = json_decode($exportedDocStr, true);
Expand Down Expand Up @@ -193,6 +193,10 @@
print_r($upsertRes);
echo "--------Upsert Documents-------\n";
echo "\n";
echo "--------Bulk Delete Documents-------\n";
print_r($client->collections['books']->documents->delete(['filter_by' => 'publication_year:=2008']));
echo "--------Bulk Delete Documents-------\n";
echo "\n";
echo "--------Delete Collection-------\n";
print_r($client->collections['books']->delete());
echo "--------Delete Collection-------\n";
Expand Down
13 changes: 12 additions & 1 deletion src/Documents.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Documents implements \ArrayAccess
public function __construct(string $collectionName, ApiCall $apiCall)
{
$this->collectionName = $collectionName;
$this->apiCall = $apiCall;
$this->apiCall = $apiCall;
}

/**
Expand Down Expand Up @@ -150,6 +150,17 @@ public function export(): string
return $this->apiCall->get($this->endPointPath('export'), [], false);
}

/**
* @param array $queryParams
*
* @return array
* @throws TypesenseClientError|GuzzleException
*/
public function delete(array $queryParams = []): array
{
return $this->apiCall->delete($this->endPointPath(), true, $queryParams);
}

/**
* @param array $searchParams
*
Expand Down
2 changes: 1 addition & 1 deletion src/Lib/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public function __construct(array $config)
$this->retryIntervalSeconds = (float)($config['retry_interval_seconds'] ?? 1.0);

$this->logLevel = $config->logLevel ?? Logger::WARNING;
$this->logger = new Logger('typesense');
$this->logger = new Logger('typesense');
$this->logger->pushHandler(new StreamHandler('php://stdout', $this->logLevel));
}

Expand Down