Skip to content

JAVA-6099 Add new fields for Auto embedding#1936

Open
strogiyotec wants to merge 3 commits intomongodb:mainfrom
strogiyotec:JAVA-6099
Open

JAVA-6099 Add new fields for Auto embedding#1936
strogiyotec wants to merge 3 commits intomongodb:mainfrom
strogiyotec:JAVA-6099

Conversation

@strogiyotec
Copy link
Copy Markdown
Contributor

@strogiyotec strogiyotec commented Apr 9, 2026

JAVA-6099
The doc in JIRA list new fields that must be supported by the drivers
but because the Search index doesn't use builders, java driver makes it possible to use new fields without changing API
As part of this PR I added a new unit test to disabled test class and enabled it locally for testing
The reason it's disabled is

  1. This class was created to add support for queryText index that was only available in custom docker image ,right now it's available in community edition so we have to adjust evergreen first
  2. New Search Index fields are only available in Atlas and are not in public preview yet, I had to use specific cluster in Atlas QA environment
    For other details please check the JIRA ticket comment

@strogiyotec strogiyotec requested a review from a team as a code owner April 9, 2026 04:55
@strogiyotec strogiyotec requested a review from rozza April 9, 2026 04:55
@codeowners-service-app
Copy link
Copy Markdown

Assigned atandon2024 for team dbx-java because rozza is out of office.

@strogiyotec strogiyotec requested review from vbabanin and removed request for atandon2024 and rozza April 9, 2026 05:20
@vbabanin vbabanin requested a review from Copilot April 9, 2026 06:40
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

Adds functional coverage for new Atlas Search “autoEmbed” index fields and related vector search behaviors in the sync driver test suite (JAVA-6099), primarily by expanding the existing automated-embedding functional test class.

Changes:

  • Adds new functional tests for auto-embedding search index creation scenarios (quantization variants, filter fields, invalid configurations).
  • Adds query coverage for model override and exact vector search options.
  • Introduces a disabled (intended-to-skip) test case for numDimensions on autoEmbed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 31 to +243
@@ -44,6 +47,7 @@
import static com.mongodb.client.model.Aggregates.vectorSearch;
import static com.mongodb.client.model.search.SearchPath.fieldPath;
import static com.mongodb.client.model.search.VectorSearchOptions.approximateVectorSearchOptions;
import static com.mongodb.client.model.search.VectorSearchOptions.exactVectorSearchOptions;
import static com.mongodb.client.model.search.VectorSearchQuery.textQuery;
import static java.util.Arrays.asList;
import static org.bson.codecs.configuration.CodecRegistries.fromProviders;
@@ -210,6 +214,200 @@ private void insertDocumentsForEmbedding() {
));
}


@ParameterizedTest(name = "should create auto embedding index with {0} quantization")
@ValueSource(strings = {"float", "scalar", "binary", "binaryNoRescore"})
void shouldCreateAutoEmbeddingIndexWithQuantization(final String quantization) {
final String indexName = INDEX_NAME + "_" + quantization;
mongoClient.getDatabase(getDatabaseName()).createCollection(getCollectionName());
SearchIndexModel indexModel = new SearchIndexModel(
indexName,
new Document(
"fields",
Collections.singletonList(
new Document("type", "autoEmbed")
.append("modality", "text")
.append("path", FIELD_SEARCH_PATH)
.append("model", "voyage-4-large")
.append("quantization", quantization)
)),
SearchIndexType.vectorSearch()
);
List<String> result = documentCollection.createSearchIndexes(Collections.singletonList(indexModel));
Assertions.assertFalse(result.isEmpty());
}

@Test
@DisplayName("should create auto embedding index with custom numDimensions")
@Ignore("Currently numDimensions can't be used, it fails with server error: 'Invalid numDimensions value for autoEmbed field in index: test_auto_embed. Expected an integer.'")
void shouldCreateAutoEmbeddingIndexWithCustomNumDimensions() {
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

This test class is using JUnit Jupiter (@test, @beforeeach, etc.), but the method is annotated with JUnit 4's @ignore. JUnit Jupiter will not honor @ignore, so when the class-level Assumption is eventually removed this test will run (and currently looks intended to be skipped). Use org.junit.jupiter.api.Disabled (or the project’s existing conditional-disable mechanism) and drop the org.junit.Ignore import.

Copilot uses AI. Check for mistakes.

@Test
@DisplayName("should create auto embedding index with custom numDimensions")
@Ignore("Currently numDimensions can't be used, it fails with server error: 'Invalid numDimensions value for autoEmbed field in index: test_auto_embed. Expected an integer.'")
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

The @Ignore reason mentions an index name test_auto_embed, but this test creates the index using INDEX_NAME (currently "voyage_4"). Consider making the ignore/disabled message generic or matching the actual index name to avoid confusion when diagnosing failures.

Suggested change
@Ignore("Currently numDimensions can't be used, it fails with server error: 'Invalid numDimensions value for autoEmbed field in index: test_auto_embed. Expected an integer.'")
@Ignore("Currently numDimensions can't be used; it fails with a server error for the autoEmbed field: 'Invalid numDimensions value for autoEmbed field. Expected an integer.'")

Copilot uses AI. Check for mistakes.
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.

2 participants