类 MongoDbEmbeddingStore

java.lang.Object
dev.langchain4j.store.embedding.mongodb.MongoDbEmbeddingStore
所有已实现的接口:
EmbeddingStore<TextSegment>

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

More info to set up MongoDb as vectorDatabase.

tutorial how to use a knn-vector in MongoDB Atlas (great starting point).

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 -> Create Index Search -> "JSON Editor" under "Atlas Search" -> Next -> Select your database in the left pane -> Insert the following JSON into the right pane (set "dimensions" and "metadata"->"fields" to desired values)

 {
   "mappings": {
     "dynamic": false,
     "fields": {
       "embedding": {
         "dimensions": 384,
         "similarity": "cosine",
         "type": "knnVector"
       },
       "metadata": {
         "dynamic": false,
         "fields": {
           "test-key": {
             "type": "token"
           }
         },
         "type": "document"
       }
     }
   }
 }
 
-> Next -> Create Search Index