From 9956d35cc606a4e71cc7a5c9c23e1ec14bdf3d57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Mon, 15 Jun 2026 14:40:32 +0200 Subject: [PATCH] PHPLIB-1789: Add autoEmbed type in VectorSearchIndexShape --- src/Collection.php | 1 + tests/Type/SearchIndexShapes.php | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/src/Collection.php b/src/Collection.php index bc808cac1..b85ff0683 100644 --- a/src/Collection.php +++ b/src/Collection.php @@ -109,6 +109,7 @@ * @psalm-type VectorSearchIndexShape = array{ * fields: list< * array{type: 'vector', path: string, numDimensions: int, similarity: 'euclidean'|'cosine'|'dotProduct', quantization?: 'none'|'scalar'|'binary', indexingMethod?: 'flat'|'hnsw', hnswOptions?: array{maxEdges?: int, numEdgeCandidates?: int}} | + * array{type: 'autoEmbed', modality: 'text', path: string, model: string, numDimensions?: int, quantization?: 'float'|'scalar'|'binary'|'binaryNoRescore', similarity?: 'euclidean'|'cosine'|'dotProduct', indexingMethod?: 'flat'|'hnsw', hnswOptions?: array{maxEdges?: int, numEdgeCandidates?: int}} | * array{type: 'filter', path: string} * >, * storedSource?: bool|array{include: list}|array{exclude: list}, diff --git a/tests/Type/SearchIndexShapes.php b/tests/Type/SearchIndexShapes.php index f5a346411..24723d2da 100644 --- a/tests/Type/SearchIndexShapes.php +++ b/tests/Type/SearchIndexShapes.php @@ -226,4 +226,48 @@ public function vectorSearchIndexWithFlatIndexingMethod(Collection $collection): ['name' => 'my_flat_index', 'type' => 'vectorSearch'], ); } + + /** @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/ */ + public function autoEmbedVectorSearchIndex(Collection $collection): void + { + $collection->createSearchIndex( + [ + 'fields' => [ + [ + 'type' => 'autoEmbed', + 'modality' => 'text', + 'path' => 'description', + 'model' => 'voyage-4', + ], + ], + ], + ['name' => 'my_auto_embed_index', 'type' => 'vectorSearch'], + ); + } + + /** @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/ */ + public function autoEmbedVectorSearchIndexWithOptions(Collection $collection): void + { + $collection->createSearchIndex( + [ + 'fields' => [ + [ + 'type' => 'autoEmbed', + 'modality' => 'text', + 'path' => 'description', + 'model' => 'voyage-4-large', + 'numDimensions' => 1024, + 'quantization' => 'scalar', + 'similarity' => 'dotProduct', + 'indexingMethod' => 'hnsw', + 'hnswOptions' => [ + 'maxEdges' => 32, + 'numEdgeCandidates' => 200, + ], + ], + ], + ], + ['name' => 'my_auto_embed_index', 'type' => 'vectorSearch'], + ); + } }