Class MongoDbEmbeddingStore

java.lang.Object
dev.langchain4j.store.embedding.mongodb.MongoDbEmbeddingStore
All Implemented Interfaces:
EmbeddingStore<TextSegment>

public class MongoDbEmbeddingStore extends Object implements EmbeddingStore<TextSegment>
Represents a MongoDB indexed collection as an embedding store.

More info on using MongoDb vector search.

tutorial how to use vector search with MongoDB Atlas (great starting point).

To deploy a local instance of Atlas, see this guide.

If you are using a free tier, #createIndex = true might not be supported, so you will need to create an index manually. In your Atlas web console go to: DEPLOYMENT -> Database -> {your cluster} -> Atlas Search tab -> Create Index Search -> "JSON Editor" under "Atlas Vector Search" (not "Atlas Search") -> Next -> Select your database in the left pane -> Insert the following JSON into the right pane (set "numDimensions" and additional metadata fields to desired values)

 {
   "fields" : [ {
     "type" : "vector",
     "path" : "embedding",
     "numDimensions" : 384,
     "similarity" : "cosine"
   }, {
     "type" : "filter",
     "path" : "metadata.test-key"
   } ]
 }
 
-> Next -> Create Search Index