Skip to content

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

@JustAnyones

Description

@JustAnyones

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions