Skip to content

Add vector quantization support (quantizerType) for Cosmos DB vector indexes#36871

Open
Copilot wants to merge 2 commits intomainfrom
copilot/add-vector-quantisation-feature
Open

Add vector quantization support (quantizerType) for Cosmos DB vector indexes#36871
Copilot wants to merge 2 commits intomainfrom
copilot/add-vector-quantisation-feature

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Dec 12, 2025

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 quantizerType property on vector indexes, enabling users to specify quantization algorithms for DiskANN and QuantizedFlat index types.

Changes:

  • Add VectorIndexQuantizationType enum with Product and Spherical values
  • Add optional quantizerType property to VectorIndex interface
  • Export new enum from public API
  • Update samples to demonstrate usage

Example:

import { VectorIndexType, VectorIndexQuantizationType } from "@azure/cosmos";

const indexingPolicy: IndexingPolicy = {
  vectorIndexes: [
    { path: "/vector1", type: VectorIndexType.Flat },
    {
      path: "/vector2",
      type: VectorIndexType.QuantizedFlat,
      quantizerType: VectorIndexQuantizationType.Product,
      quantizationByteSize: 2,
    },
    {
      path: "/vector3",
      type: VectorIndexType.DiskANN,
      quantizerType: VectorIndexQuantizationType.Spherical,
      quantizationByteSize: 2,
      indexingSearchListSize: 50,
    },
  ],
};

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.ts to validate container creation with quantizerType for both Product and Spherical values.

Provide a list of related PRs (if any)

Command used to generate this PR:**(Applicable only to SDK release request PRs)

N/A

Checklists

  • Added impacted package name to the issue description
  • Does this PR needs any fixes in the SDK Generator?** (If so, create an Issue in the Autorest/typescript repository and link it here)
  • Added a changelog (if necessary)

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
    • Triggering command: /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

this is the PR in .NET SDK Azure/azure-cosmos-dotnet-v3#5502
for vector quantisation feature, i want u to 1st understand the code structre of comos db JS SDK, how vector search is supported and add this feature there


💡 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.

…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>
Copilot AI changed the title [WIP] Add vector quantisation feature to JavaScript SDK Add vector quantization support (quantizerType) for Cosmos DB vector indexes Dec 12, 2025
Copilot AI requested a review from topshot99 December 12, 2025 09:52
@topshot99 topshot99 marked this pull request as ready for review February 6, 2026 06:46
Copilot AI review requested due to automatic review settings February 6, 2026 06:46
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 VectorIndexQuantizationType enum with Product and Spherical values
  • Added optional quantizerType property to the VectorIndex interface
  • 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

@github-actions
Copy link
Copy Markdown
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants