Skip to content

Commit 7ba853f

Browse files
authored
PHPLIB-1789: Add autoEmbed type in VectorSearchIndexShape (#1926)
1 parent e208a44 commit 7ba853f

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/Collection.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@
109109
* @psalm-type VectorSearchIndexShape = array{
110110
* fields: list<
111111
* array{type: 'vector', path: string, numDimensions: int, similarity: 'euclidean'|'cosine'|'dotProduct', quantization?: 'none'|'scalar'|'binary', indexingMethod?: 'flat'|'hnsw', hnswOptions?: array{maxEdges?: int, numEdgeCandidates?: int}} |
112+
* 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}} |
112113
* array{type: 'filter', path: string}
113114
* >,
114115
* storedSource?: bool|array{include: list<string>}|array{exclude: list<string>},

tests/Type/SearchIndexShapes.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,4 +226,48 @@ public function vectorSearchIndexWithFlatIndexingMethod(Collection $collection):
226226
['name' => 'my_flat_index', 'type' => 'vectorSearch'],
227227
);
228228
}
229+
230+
/** @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/ */
231+
public function autoEmbedVectorSearchIndex(Collection $collection): void
232+
{
233+
$collection->createSearchIndex(
234+
[
235+
'fields' => [
236+
[
237+
'type' => 'autoEmbed',
238+
'modality' => 'text',
239+
'path' => 'description',
240+
'model' => 'voyage-4',
241+
],
242+
],
243+
],
244+
['name' => 'my_auto_embed_index', 'type' => 'vectorSearch'],
245+
);
246+
}
247+
248+
/** @see https://www.mongodb.com/docs/atlas/atlas-vector-search/vector-search-type/ */
249+
public function autoEmbedVectorSearchIndexWithOptions(Collection $collection): void
250+
{
251+
$collection->createSearchIndex(
252+
[
253+
'fields' => [
254+
[
255+
'type' => 'autoEmbed',
256+
'modality' => 'text',
257+
'path' => 'description',
258+
'model' => 'voyage-4-large',
259+
'numDimensions' => 1024,
260+
'quantization' => 'scalar',
261+
'similarity' => 'dotProduct',
262+
'indexingMethod' => 'hnsw',
263+
'hnswOptions' => [
264+
'maxEdges' => 32,
265+
'numEdgeCandidates' => 200,
266+
],
267+
],
268+
],
269+
],
270+
['name' => 'my_auto_embed_index', 'type' => 'vectorSearch'],
271+
);
272+
}
229273
}

0 commit comments

Comments
 (0)