文档API 参考📓 教程🧑‍🍳 食谱🤝 集成💜 Discord🎨 Studio
文档

MongoDBAtlasDocumentStore

MongoDBAtlasDocumentStore 可用于使用 MongoDB Atlas 管理文档,MongoDB Atlas 是 MongoDB 公司提供的多云数据库服务。Atlas 简化了数据库的部署和管理,同时提供了构建具有弹性和高性能的全球应用程序所需的灵活性,这些应用程序可以在您选择的云提供商上运行。您可以在 AWS、Azure 或 Google Cloud 等云提供商上使用 MongoDB Atlas,而无需离开 Atlas 的 Web UI。

MongoDB Atlas 支持嵌入向量,因此可用于嵌入检索。

安装

要将 MongoDB Atlas 与 Haystack 一起使用,请先安装集成。

pip install mongodb-atlas-haystack

初始化

要将 MongoDB Atlas 与 Haystack 一起使用,您需要创建 MongoDB Atlas 账户:请参阅 MongoDB Atlas 文档 获取帮助。您还需要为您计划使用的集合 创建一个向量搜索索引一个全文搜索索引

获取连接字符串后,应将其导出到一个名为MONGO_CONNECTION_STRING 的环境变量中。它应该看起来像这样:

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

此时,您就可以初始化存储了。

from haystack_integrations.document_stores.mongodb_atlas import MongoDBAtlasDocumentStore

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

支持的 Retrievers