Add vector quantization support (quantizerType) for Cosmos DB vector indexes#36871
Add vector quantization support (quantizerType) for Cosmos DB vector indexes#36871
Conversation
…ector indexes - Add VectorIndexQuantizationType enum with Product and Spherical values - Add optional quantizerType property to VectorIndex interface - Export VectorIndexQuantizationType from src/index.ts - Update samples to demonstrate the new quantizerType property - Add test case for quantizerType in NonStreamingQueryPolicy.spec.ts - Update CHANGELOG.md with the new feature Co-authored-by: topshot99 <113669638+topshot99@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds support for vector quantization in Cosmos DB by introducing the quantizerType property for vector indexes. This feature enables users to specify quantization algorithms (Product or Spherical) for DiskANN and QuantizedFlat index types, consistent with the implementation in the .NET SDK.
Changes:
- Added
VectorIndexQuantizationTypeenum withProductandSphericalvalues - Added optional
quantizerTypeproperty to theVectorIndexinterface - Updated public API exports, tests, samples, and documentation
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/cosmosdb/cosmos/src/documents/IndexingPolicy.ts | Added VectorIndexQuantizationType enum and quantizerType property to VectorIndex interface with proper documentation |
| sdk/cosmosdb/cosmos/src/index.ts | Exported VectorIndexQuantizationType enum from public API |
| sdk/cosmosdb/cosmos/test/public/functional/NonStreamingQueryPolicy.spec.ts | Added comprehensive test case validating both Product and Spherical quantizer types, including verification that Flat index doesn't have quantizerType |
| sdk/cosmosdb/cosmos/samples/v4/typescript/src/ContainerManagement.ts | Updated TypeScript sample to demonstrate quantizerType usage with both Product and Spherical values |
| sdk/cosmosdb/cosmos/samples/v4/javascript/ContainerManagement.js | Updated JavaScript sample to demonstrate quantizerType usage with both Product and Spherical values |
| sdk/cosmosdb/cosmos/samples-dev/ContainerManagement.ts | Updated samples-dev to demonstrate quantizerType usage with both Product and Spherical values |
| sdk/cosmosdb/cosmos/review/cosmos-node.api.md | Added VectorIndexQuantizationType enum to public API surface documentation |
| sdk/cosmosdb/cosmos/CHANGELOG.md | Added feature documentation for quantizerType support in the 4.9.0 release |
|
Hi @copilot. Thank you for your interest in helping to improve the Azure SDK experience and for your contribution. We've noticed that there hasn't been recent engagement on this pull request. If this is still an active work stream, please let us know by pushing some changes or leaving a comment. Otherwise, we'll close this out in 7 days. |
Packages impacted by this PR
@azure/cosmos
Issues associated with this PR
Ports vector quantization feature from .NET SDK: Azure/azure-cosmos-dotnet-v3#5502
Describe the problem that is addressed by this PR
Adds support for the
quantizerTypeproperty on vector indexes, enabling users to specify quantization algorithms forDiskANNandQuantizedFlatindex types.Changes:
VectorIndexQuantizationTypeenum withProductandSphericalvaluesquantizerTypeproperty toVectorIndexinterfaceExample:
What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen?
Follows the same design pattern as the .NET SDK implementation—enum for type safety, optional property to maintain backward compatibility.
Are there test cases added in this PR? (If not, why?)
Yes. Added test case in
NonStreamingQueryPolicy.spec.tsto validate container creation withquantizerTypefor bothProductandSphericalvalues.Provide a list of related PRs (if any)
Command used to generate this PR:**(Applicable only to SDK release request PRs)
N/A
Checklists
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
test-account.documents.azure.com/opt/hostedtoolcache/node/20.19.6/x64/bin/node /opt/hostedtoolcache/node/20.19.6/x64/bin/node --conditions node --conditions development --experimental-import-meta-resolve --require /home/REDACTED/work/azure-sdk-for-js/azure-sdk-for-js/node_modules/.pnpm/vitest@4.0.15_@opentelemetry+api@1.9.0_@types+node@20.19.25_@vitest+browser-playwright@_48061486853d865002b73f2733bb734d/node_modules/vitest/suppress-warnings.cjs /home/REDACTED/work/azure-sdk-for-js/azure-sdk-for-js/node_modules/.pnpm/vitest@4.0.15_@opentelemetry+api@1.9.0_@types+node@20.19.25_@vitest+browser-playwright@_48061486853d865002b73f2733bb734d/node_modules/vitest/dist/workers/forks.js(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.