feat: Supabase pgvector tables, HNSW indexes, RPC functions 추가 - #13
Merged
Conversation
20 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📌 관련 이슈
closes #6
📝 작업 내용
벡터DB 스키마 설계에 정의된 벡터 검색 인프라를 Supabase에 구축.테이블 3종 + HNSW 인덱스
product_embeddings(feature_vec vector(1024))— HNSW cosinereview_embeddings(embedding vector(1024))— HNSW + product_id 인덱스user_context_rags(embedding vector(1024))— HNSW + (user_id, category, created_at) 인덱스RPC 함수 4종 (service_role 권한)
match_products(query, category, count, exclude_ids)— discovery 후보 검색match_alternatives(base_product_id, count, exclude_ids)— 대체 상품 검색match_reviews(query, product_id, count)— review_score 계산match_user_contexts(user_id, query, category, count)— RAG 검색Supabase Dashboard SQL Editor에서 001~008 순서대로 적용. 적용 후 더미 쿼리로 동작 확인:
📁 변경 파일
AI/db/migrations/001_enable_pgvector.sqlAI/db/migrations/002_create_product_embeddings.sqlAI/db/migrations/003_create_review_embeddings.sqlAI/db/migrations/004_create_user_context_rags.sqlAI/db/migrations/005_rpc_match_products.sqlAI/db/migrations/006_rpc_match_alternatives.sqlAI/db/migrations/007_rpc_match_reviews.sqlAI/db/migrations/008_rpc_match_user_contexts.sqlAI/scripts/apply_migrations.py✅ 체크리스트
SELECT proname FROM pg_proc WHERE proname LIKE 'match_%';→ 4건 확인