Skip to main content

MongoDB Atlas and Vector Search

MongoDB Atlas is a fully-managed cloud database available in AWS, Azure, and GCP. It supports native Vector Search and full text search (BM25) on your MongoDB document data.

MongoDB Atlas Vector Search allows you to store your embeddings in MongoDB documents, create vector search indexes, and perform KNN search with an approximate nearest neighbor algorithm called Hierarchical Navigable Small Worlds. You can implement this feature by using the $vectorSearch MQL aggregation stage.

Prerequisites

You must have an Atlas cluster that runs one of the following MongoDB versions:

  • 6.0.11
  • 7.0.2
  • Later versions (including Release Candidates).

To use Atlas Vector search, you need to have an Atlas deployment. MongoDB offers a free forever cluster that you can use for testing. See the Get Started with Atlas tutorial to learn more. Once you deploy a cluster, you can create a vector search index by using the index JSON editor.

Maven Dependency

<dependency>
<groupId>dev.langchain4j</groupId>
<artifactId>langchain4j-mongodb-atlas</artifactId>
<version>0.35.0</version>
</dependency>

APIs

  • MongoDbEmbeddingStore

Examples