JAVA-6099 Add new fields for Auto embedding#1936
JAVA-6099 Add new fields for Auto embedding#1936strogiyotec wants to merge 3 commits intomongodb:mainfrom
Conversation
|
Assigned |
There was a problem hiding this comment.
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
numDimensionsonautoEmbed.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -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() { | |||
There was a problem hiding this comment.
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.
|
|
||
| @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.'") |
There was a problem hiding this comment.
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.
| @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.'") |
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
For other details please check the JIRA ticket comment