fix(backend): set search_path for vector type visibility in hybrid search

- Add SET LOCAL search_path TO platform, public; to queries using vector types
- This ensures the vector type is found while keeping operators working
- Fixes hybrid search on databases using platform schema

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Swifty
2026-01-09 18:45:29 +01:00
parent 9cfe70e554
commit 5f0a39bbf0
2 changed files with 5 additions and 0 deletions

View File

@@ -108,8 +108,10 @@ async def store_embedding(
embedding_str = "[" + ",".join(str(x) for x in embedding) + "]"
# Upsert the embedding
# Set search_path to include public for vector type visibility
await client.execute_raw(
"""
SET LOCAL search_path TO platform, public;
INSERT INTO platform."StoreListingEmbedding" (
"id", "storeListingVersionId", "embedding",
"searchableText", "contentHash", "createdAt", "updatedAt"

View File

@@ -147,7 +147,9 @@ async def hybrid_search(
# Build hybrid search query with weighted scoring
# The semantic score is (1 - cosine_distance), normalized to [0,1]
# The lexical score is ts_rank_cd, normalized by max value
# Set search_path to include public for vector type visibility
sql_query = f"""
SET LOCAL search_path TO platform, public;
WITH search_scores AS (
SELECT
sa.*,
@@ -224,6 +226,7 @@ async def hybrid_search(
# Count query - must also filter by min_score
count_query = f"""
SET LOCAL search_path TO platform, public;
WITH search_scores AS (
SELECT
sa.slug,