Skip to content

VectorIndex Policy: Adds Support for QuantizerType in IndexingPolicy#47566

Merged
allenkim0129 merged 24 commits intoAzure:mainfrom
allenkim0129:users/allekim/vector_quantizertype
Jan 23, 2026
Merged

VectorIndex Policy: Adds Support for QuantizerType in IndexingPolicy#47566
allenkim0129 merged 24 commits intoAzure:mainfrom
allenkim0129:users/allekim/vector_quantizertype

Conversation

@allenkim0129
Copy link
Copy Markdown
Contributor

@allenkim0129 allenkim0129 commented Dec 15, 2025

Description

  • Add a new field "quantizerType": "product/spherical" to vector index definition in indexing policy.

Example:

        CosmosVectorIndexSpec cosmosVectorIndexSpec = new CosmosVectorIndexSpec()
            .setPath("/vector2")
            .setType(CosmosVectorIndexType.QUANTIZED_FLAT.toString())
            .setQuantizerType(QuantizerType.product)
            .setQuantizationSizeInBytes(2)
            .setVectorIndexShardKeys(Arrays.asList("/zipCode"));

Type of change

Testing against a live account that has Vector Search for NoSQL API feature enabled:

  • Ran e2e test and created a container with:
        IndexingPolicy indexingPolicy = new IndexingPolicy()
            .setIndexingMode(IndexingMode.CONSISTENT)
            .setExcludedPaths(Collections.singletonList(excludedPath))
            .setIncludedPaths(ImmutableList.of(includedPath1, includedPath2))
            .setVectorIndexes(populateVectorIndexes());

      private List<CosmosVectorIndexSpec> populateVectorIndexes() {
              CosmosVectorIndexSpec cosmosVectorIndexSpec1 = new CosmosVectorIndexSpec()
                  .setPath("/vector1")
                  .setType(CosmosVectorIndexType.FLAT.toString());
      
              CosmosVectorIndexSpec cosmosVectorIndexSpec2 = new CosmosVectorIndexSpec()
                  .setPath("/vector2")
                  .setType(CosmosVectorIndexType.QUANTIZED_FLAT.toString())
                  .setQuantizerType(QuantizerType.product)
                  .setQuantizationSizeInBytes(2);
      
              CosmosVectorIndexSpec cosmosVectorIndexSpec3 = new CosmosVectorIndexSpec()
                  .setPath("/vector3")
                  .setType(CosmosVectorIndexType.DISK_ANN.toString())
                  .setQuantizerType(QuantizerType.product)
                  .setQuantizationSizeInBytes(2)
                  .setIndexingSearchListSize(30);
      
              CosmosVectorIndexSpec cosmosVectorIndexSpec4 = new CosmosVectorIndexSpec()
                  .setPath("/vector4")
                  .setType(CosmosVectorIndexType.DISK_ANN.toString())
                  .setQuantizerType(QuantizerType.spherical)
                  .setIndexingSearchListSize(30);
      
              return Arrays.asList(cosmosVectorIndexSpec1, cosmosVectorIndexSpec2, cosmosVectorIndexSpec3, cosmosVectorIndexSpec4);
          }

Check in portal and it has the quantizerTyupe value configured as product/spherical
Screenshot 2025-12-15 at 2 34 53 PM

All SDK Contribution checklist:

  • The pull request does not introduce [breaking changes]
  • CHANGELOG is updated for new features, bug fixes or other significant changes.
  • I have read the contribution guidelines.

General Guidelines and Best Practices

  • Title of the pull request is clear and informative.
  • There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, see this page.

Testing Guidelines

  • Pull request includes test coverage for the included changes.

@allenkim0129 allenkim0129 marked this pull request as ready for review December 15, 2025 22:54
Copilot AI review requested due to automatic review settings December 15, 2025 22:54
@allenkim0129 allenkim0129 requested review from a team as code owners December 15, 2025 22:54
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 pull request adds support for quantizer types in vector index specifications for Azure Cosmos DB. The main purpose is to allow users to specify either "product" or "spherical" quantizer types when defining vector indexes in the indexing policy.

Key Changes:

  • Introduced a new QuantizerType enum with two values: product and spherical
  • Added quantizerType field to CosmosVectorIndexSpec with corresponding getter/setter methods
  • Updated CosmosVectorEmbeddingPolicy.setCosmosVectorEmbeddings() to return the policy instance for fluent API consistency
  • Enhanced tests to validate serialization/deserialization of the new quantizer type field

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 11 comments.

Show a summary per file
File Description
QuantizerType.java New enum defining product and spherical quantizer types for vector indexes
CosmosVectorIndexSpec.java Added quantizerType field with getter/setter methods to support the new property
CosmosVectorEmbeddingPolicy.java Changed setCosmosVectorEmbeddings to return policy instance for fluent API pattern
Constants.java Added QUANTIZER_TYPE constant for JSON property serialization
CHANGELOG.md Documented the new QuantizerType feature
VectorIndexTest.java Updated tests to validate quantizer type serialization/deserialization and refactored test code to use fluent builder pattern

Comment thread sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/QuantizerType.java Outdated
Comment thread sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/QuantizerType.java Outdated
Comment thread sdk/cosmos/azure-cosmos/src/main/java/com/azure/cosmos/models/QuantizerType.java Outdated
Copy link
Copy Markdown
Member

@simorenoh simorenoh left a comment

Choose a reason for hiding this comment

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

Just one comment, LGTM otherwise

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Dec 16, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

com.azure:azure-cosmos

@allenkim0129 allenkim0129 enabled auto-merge (squash) December 23, 2025 19:39
@allenkim0129 allenkim0129 merged commit 9ad5729 into Azure:main Jan 23, 2026
34 checks passed
jeet1995 added a commit to jeet1995/azure-sdk-for-java that referenced this pull request Apr 10, 2026
Add review rules for sdk/cosmos/ that the PR Deep Reviewer agent consumes
as mandatory constraints. These encode Cosmos-specific knowledge the agent
cannot infer on its own:

- @beta annotation gating for preview APIs (addresses PR Azure#47566 miss)
- Public enum extensibility scrutiny
- Azure SDK Java central guidelines check (new client surface only)
- Java 8 baseline compatibility
- Suppressions: CHANGELOG per-PR, API contract artifacts, CheckStyle disabling
- Domain emphasis: multi-region failover, retry/timeout criticality

Modeled after the .NET Cosmos SDK precedent (Azure/azure-cosmos-dotnet-v3).
Tested with pragentrules-resolver against PR Azure#47566 changed files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jeet1995 added a commit to jeet1995/azure-sdk-for-java that referenced this pull request Apr 10, 2026
Add review rules for sdk/cosmos/ that the PR Deep Reviewer agent consumes
as mandatory constraints. These encode Cosmos-specific knowledge the agent
cannot infer on its own:

- @beta annotation gating for preview APIs (addresses PR Azure#47566 miss)
- Public enum extensibility scrutiny
- Azure SDK Java central guidelines check (new client surface only)
- Java 8 baseline compatibility
- Suppressions: CHANGELOG per-PR, API contract artifacts, CheckStyle disabling
- Domain emphasis: multi-region failover, retry/timeout criticality

Modeled after the .NET Cosmos SDK precedent (Azure/azure-cosmos-dotnet-v3).
Tested with pragentrules-resolver against PR Azure#47566 changed files.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants