Skip to content

Conversation

@allenkim0129
Copy link
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
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

Copy link
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
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
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.

2 participants