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
MongoDBAtlasEmbeddingRetriever:比较查询和文档的嵌入向量,并获取与查询最相关的文档。MongoDBAtlasFullTextRetriever:一个全文搜索检索器。
更新于 6 个月前
