Skip to content

Instantly share code, notes, and snippets.

@flyingwebie
Created August 27, 2025 23:41
Show Gist options
  • Save flyingwebie/7f5f9ad7585ca0219d9cae3910895aa6 to your computer and use it in GitHub Desktop.
Save flyingwebie/7f5f9ad7585ca0219d9cae3910895aa6 to your computer and use it in GitHub Desktop.
-- 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;
$$;
@flyingwebie
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment