概要
Notionは2022〜2024年にかけて、AI機能(Notion AI)のためにデータ基盤を根本から刷新しました。
アーキテクチャ
[Notion App DB]
│
Debezium CDC
│
[Kafka]
│
┌────┴────┐
│ │
[Hudi] [Spark]
│ │
└────┬────┘
│
[S3 Data Lake]
│
[Embedding Pipeline]
│
[Vector Index]
技術的課題: 権限情報の伝播
Notionの最大の課題は、データの権限情報をRAGシステムに正しく伝播することでした。
# Notionの権限ツリー構造(概念コード)
@dataclass
class NotionPage:
id: str
content: str
parent_id: str | None
permissions: list[str] # ["user:123", "team:engineering"]
def resolve_permissions(page: NotionPage, pages: dict) -> set[str]:
"""ページの実効権限を解決(親からの継承を含む)"""
perms = set(page.permissions)
if page.parent_id and page.parent_id in pages:
parent = pages[page.parent_id]
perms |= resolve_permissions(parent, pages) # 再帰的に親の権限を継承
return perms
def create_rag_document(page: NotionPage, pages: dict) -> dict:
"""RAG用ドキュメント(権限メタデータ付き)"""
return {
"text": page.content,
"metadata": {
"page_id": page.id,
"permitted_users": list(resolve_permissions(page, pages)),
"last_updated": datetime.now().isoformat(),
},
}
フィルタリング付き検索
def search_with_permissions(query: str, user_id: str, vector_store):
"""権限を考慮したRAG検索"""
results = vector_store.similarity_search(
query=query,
k=10,
filter={"permitted_users": {"$contains": user_id}},
)
return results
CEOの発言
"RAG is the future of knowledge management." — Ivan Zhao, Notion CEO
成果
- リアルタイムCDCでデータの鮮度を維持
- 権限ベースフィルタリングで安全なRAG検索を実現
- Notion AI の基盤として全ユーザーに展開