spring-projects / spring-projects/spring-ai
MongoDBAtlasVectorStore ignores custom pathName and always writes embeddings to "embedding" field
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 9.5k
- Forks
- 2.9k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 6
Description
Bug description
When using MongoDBAtlasVectorStore from Spring AI (configured with a custom pathName for the embedding field), the doAdd() logic always writes the embedding into a field named "embedding" (via the MongoDBDocument record). As a result, vector searches fail because the Atlas vector search index looks for vectors under the configured pathName (e.g., "custom_embedding"), but the field in the database does not match.
Environment
- Spring AI version: 1.0.3
- Java version: Java 25
- Vector store: MongoDB Atlas Vector Store
- MongoDB version: Atlas cluster running 8.0.15
Steps to reproduce
- Configure
MongoDBAtlasVectorStore.builder(...)with.pathName("custom_embedding"). - Call
vectorStore.add(List.of(new Document("some text"))). - Inspect the collection in MongoDB and notice that the document has the field
"embedding"instead of"custom_embedding".
Expected behavior
The embeddings should be stored under the field specified by pathName. For example, if pathName("custom_embedding") is configured, the saved document should have a "custom_embedding" field containing the vector.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at MongoDBAtlasVectorStore.doAdd() and inspect how the MongoDBDocument record represents the embedding field. Reproduce the issue with pathName("custom_embedding") and check the stored document in MongoDB; done means the vector is written under the configured pathName instead of "embedding".
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, mongodb
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100