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 src/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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}} |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we multiline these types of shapes with a lot of different fields? Would make it easier to read the diff

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have mixed feelings about it, because it also makes the docblock very, very long.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, but now it's also long, but horizontally, and hard to read 😅 But I see what you mean. It's not aesthetically pleasing but will make it easier to see what's changed.

* array{type: 'filter', path: string}
* >,
* storedSource?: bool|array{include: list<string>}|array{exclude: list<string>},
Expand Down
44 changes: 44 additions & 0 deletions tests/Type/SearchIndexShapes.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
);
}
}
Loading