spring-projects / spring-projects/spring-ai

MongoDBAtlasVectorStore ignores custom pathName and always writes embeddings to "embedding" field

Open
#4,823 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
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

  1. Configure MongoDBAtlasVectorStore.builder(...) with .pathName("custom_embedding").
  2. Call vectorStore.add(List.of(new Document("some text"))).
  3. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.