MongoDBAtlasDocumentStore
MongoDBAtlasDocumentStore
Haystack에서 문서를 관리할 때 MongoDB Atlas를 쓰고 싶다면 MongoDBAtlasDocumentStore를 이용해요. MongoDB Atlas는 MongoDB를 만든 회사가 제공하는 멀티 클라우드 데이터베이스 서비스예요. Atlas는 데이터베이스의 배포와 관리를 단순화하면서도, 원하는 클라우드 공급자 위에서 복원력 있고 성능 좋은 글로벌 애플리케이션을 만들 수 있는 유연성을 제공해요. AWS, Azure, Google Cloud 같은 클라우드 공급자를 Atlas의 웹 UI를 벗어나지 않고도 쓸 수 있어요.
MongoDB Atlas는 임베딩을 지원해서, 임베딩 기반 검색(embedding retrieval)에 쓸 수 있어요.
설치 (Installation)
Haystack에서 MongoDB Atlas를 쓰려면 먼저 통합을 설치해요.
pip install mongodb-atlas-haystack
초기화 (Initialization)
Haystack에서 MongoDB Atlas를 쓰려면 먼저 MongoDB Atlas 계정을 만들어야 해요. MongoDB Atlas 문서를 참고하면 도움이 돼요. 사용할 컬렉션에는 벡터 검색 인덱스와 전체 텍스트 검색 인덱스도 만들어 줘야 해요.
연결 문자열(connection string)을 확보했다면, MONGO_CONNECTION_STRING이라는 환경 변수로 export해요. 대략 아래와 같은 모양이에요.
export MONGO_CONNECTION_STRING="mongodb+srv://<username>:***@<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",
)
지원하는 Retriever
MongoDBAtlasEmbeddingRetriever: 쿼리와 문서 임베딩을 비교해 쿼리와 가장 관련 있는 문서를 가져와요.MongoDBAtlasFullTextRetriever: 전체 텍스트 검색 기반 Retriever예요.
출처: 공식문서