DocumentationAPI Reference📓 Tutorials🧑‍🍳 Cookbook🤝 Integrations💜 Discord🎨 Studio
Documentation

MongoDBAtlasDocumentStore

MongoDBAtlasDocumentStore can be used to manage documents using MongoDB Atlas, a multi-cloud database service by the same people who build MongoDB. Atlas simplifies deploying and managing your databases while offering the versatility you need to build resilient and performant global applications on the cloud providers of your choice. You can use MongoDB Atlas on cloud providers such as AWS, Azure, or Google Cloud, all without leaving Atlas' web UI.

MongoDB Atlas supports embeddings and can therefore be used for embedding retrieval.

Installation

To use MongoDB Atlas with Haystack, install the integration first:

pip install mongodb-atlas-haystack

Initialization

To use MongoDB Atlas with Haystack, you will need to create your MongoDB Atlas account: check the MongoDB Atlas documentation for help. You also need to create a vector search index for the collection you plan to use.

Once you have your connection string, you should export it in an environment variable called MONGO_CONNECTION_STRING. It should look something like this:

export MONGO_CONNECTION_STRING="mongodb+srv://<username>:<password>@<cluster_name>.gwkckbk.mongodb.net/?retryWrites=true&w=majority"

At this point, you’re ready to initialize the store:

# Initialize the document store
document_store = MongoDBAtlasDocumentStore(
    database_name="haystack_test",
    collection_name="test_collection",
    vector_search_index="embedding_index",
)

Supported Retrievers

MongoDBAtlasEmbeddingRetriever: Compares the query and document embeddings and fetches the documents most relevant to the query.