Created
August 27, 2025 23:41
-
-
Save flyingwebie/7f5f9ad7585ca0219d9cae3910895aa6 to your computer and use it in GitHub Desktop.
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
-- Enable the pgvector extension to work with embedding vectors | |
create extension vector; | |
-- Create a table to store your biography | |
create table biography ( | |
id bigserial primary key, | |
content text, -- corresponds to Document.pageContent | |
metadata jsonb, -- corresponds to Document.metadata | |
embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed | |
); | |
-- Create a function to search for biography | |
create function match_biography ( | |
query_embedding vector(1536), | |
match_count int default null, | |
filter jsonb DEFAULT '{}' | |
) returns table ( | |
id bigint, | |
content text, | |
metadata jsonb, | |
similarity float | |
) | |
language plpgsql | |
set search_path = public, extensions | |
as $$ | |
#variable_conflict use_column | |
begin | |
return query | |
select | |
id, | |
content, | |
metadata, | |
1 - (biography.embedding <=> query_embedding) as similarity | |
from biography | |
where metadata @> filter | |
order by biography.embedding <=> query_embedding | |
limit match_count; | |
end; | |
$$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fix Error: 42883 operator does not exist: extensions.vector <=> extensions.vector in N8N Self-hosted and Supabase Self-hosted
line n.24 =
set search_path = public, extensions
fix the issue