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.