PHPLIB-1789: Add autoEmbed type in VectorSearchIndexShape#1926
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends the library’s Psalm typing for Atlas Vector Search index definitions so that vector search indexes can declare fields entries using the autoEmbed field type, and validates the new shape via Psalm type-check fixtures.
Changes:
- Expanded
VectorSearchIndexShape(Psalm array shape) to include anautoEmbedfield variant alongside existingvectorandfiltervariants. - Added Psalm-only type fixture methods covering a minimal
autoEmbeddefinition and one including optional tuning parameters.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/Collection.php |
Adds an autoEmbed alternative to the VectorSearchIndexShape['fields'] union so createSearchIndex() accepts the new field configuration in static analysis. |
tests/Type/SearchIndexShapes.php |
Adds two Psalm type fixtures to ensure autoEmbed vector search index definitions are accepted. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
paulinevos
reviewed
Jun 16, 2026
| * @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}} | |
Contributor
There was a problem hiding this comment.
Can we multiline these types of shapes with a lot of different fields? Would make it easier to read the diff
Member
Author
There was a problem hiding this comment.
I have mixed feelings about it, because it also makes the docblock very, very long.
paulinevos
approved these changes
Jun 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds
type: 'autoEmbed'to theVectorSearchIndexShapePsalm type inCollection.php, with the following fields:type,modality('text'),path,model(string)numDimensions,quantization('float'|'scalar'|'binary'|'binaryNoRescore'),similarity,indexingMethod,hnswOptionsThe
modelfield is typed asstringrather than a string enum to avoid having to update the type every time a new model is released.Two Psalm type tests added in
SearchIndexShapes.php.Jira: https://jira.mongodb.org/browse/PHPLIB-1789