From aff6bd42d2e2a6d2b873b44b13d60412959b39a7 Mon Sep 17 00:00:00 2001 From: Ahmad Haidar Date: Mon, 13 Jan 2025 10:22:18 +0300 Subject: [PATCH] fix: set order direction explicitly --- memory-store/migrations/000022_vector_search.up.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memory-store/migrations/000022_vector_search.up.sql b/memory-store/migrations/000022_vector_search.up.sql index f0fc710fd..40866f920 100644 --- a/memory-store/migrations/000022_vector_search.up.sql +++ b/memory-store/migrations/000022_vector_search.up.sql @@ -64,12 +64,12 @@ BEGIN AND (d.embedding <=> $1) <= $2 %s %s - ORDER BY (d.embedding <=> $1) + ORDER BY (d.embedding <=> $1) ASC LIMIT ($3 * 4) -- Get more candidates than needed ) SELECT DISTINCT ON (doc_id) * FROM ranked_docs - ORDER BY doc_id, distance + ORDER BY doc_id, distance ASC LIMIT $3', owner_filter_sql, metadata_filter_sql