Skip to content

Commit d9bf1c1

Browse files
Update README for namespace, enum, and new operators
1 parent 1e141f2 commit d9bf1c1

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

README.md

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -373,10 +373,10 @@ Filter search results by document metadata. Filters can be combined with any sea
373373

374374
### Creating filters
375375

376-
Use the `MetadataFilter` value object. All nine operators are supported:
376+
Use the `MetadataFilter` value object. All eleven operators are supported:
377377

378378
```php
379-
use PHPVector\MetadataFilter;
379+
use PHPVector\Metadata\MetadataFilter;
380380

381381
// Equality / inequality
382382
$filter = MetadataFilter::eq('status', 'published');
@@ -394,14 +394,18 @@ $filter = MetadataFilter::notIn('status', ['deleted', 'archived']);
394394

395395
// Array containment — checks if metadata array contains the value
396396
$filter = MetadataFilter::contains('tags', 'php'); // matches ['tags' => ['php', 'vector']]
397+
398+
// Existence checks — does a metadata key exist (regardless of value)?
399+
$filter = MetadataFilter::exists('thumbnail');
400+
$filter = MetadataFilter::notExists('deleted_at');
397401
```
398402

399403
### Filtering search results
400404

401405
Pass filters to any search method. Multiple filters are ANDed together by default.
402406

403407
```php
404-
use PHPVector\MetadataFilter;
408+
use PHPVector\Metadata\MetadataFilter;
405409

406410
// Vector search with filters
407411
$results = $db->vectorSearch(
@@ -464,6 +468,11 @@ $results = $db->vectorSearch(
464468
filters: [MetadataFilter::eq('rare_tag', 'value')],
465469
overFetch: 10,
466470
);
471+
472+
// Or set the default multiplier at construction time
473+
$db = new VectorDatabase(
474+
overFetchMultiplier: 10,
475+
);
467476
```
468477

469478
> **Note:** Filtered queries may return fewer than `k` results if not enough documents match.
@@ -500,6 +509,8 @@ The `patchMetadata()` method:
500509
Query documents by metadata alone, without a vector or text query:
501510

502511
```php
512+
use PHPVector\Metadata\SortDirection;
513+
503514
// Find all documents matching filters
504515
$results = $db->metadataSearch(
505516
filters: [MetadataFilter::eq('status', 'published')],
@@ -515,7 +526,7 @@ $results = $db->metadataSearch(
515526
$results = $db->metadataSearch(
516527
filters: [MetadataFilter::eq('status', 'published')],
517528
sortBy: 'created_at',
518-
sortDirection: 'desc', // 'asc' or 'desc'
529+
sortDirection: SortDirection::Desc,
519530
);
520531

521532
// Empty filters returns all documents

0 commit comments

Comments
 (0)