Find answers from the community

Updated 2 months ago

Supabase Vector query error

Hi - I'm having trouble reading from my SupabaseVectorStore. when i try to do this:
Plain Text
index = VectorStoreIndex.from_vector_store(vector_store=vector_store)
query_engine = index.as_query_engine()
response = query_engine.query("my query is here")

i get this error:
Plain Text
sqlalchemy.exc.ProgrammingError: (psycopg2.errors.UndefinedFunction) operator does not exist: extensions.vector <=> unknown
LINE 1: SELECT vecs.test1.id, vecs.test1.vec <=> '[-0.01009003072977...
                                             ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.

[SQL: SELECT vecs.test1.id, vecs.test1.vec <=> %(vec_1)s AS anon_1, vecs.test1.metadata 
FROM vecs.test1 ORDER BY vecs.test1.vec <=> %(vec_1)s 
 LIMIT %(param_1)s]

somehow it's not seeing the passed in vector as a postgres vector data type. it works if i manually paste in a vector and run this query though.

any ideas? thank you!
B
L
9 comments
i was that postgres/Supabase is not listed on this page
https://gpt-index.readthedocs.io/en/latest/how_to/storage/customization.html#vector-store-integrations-and-storage
is that possibly just stale docs, or is this functionality not working?
It's stale docs, this should be working
Did you install the pgvector extension in your databse?
thanks Logan! yes, generally the vectors are working. and i can write to it using
Plain Text
storage_context = StorageContext.from_defaults(vector_store=vector_store)
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context)

but getting this error when later querying against this index 😟
Hmmm that's weird. I wonder if it's an issue with your supabase setup?

Under the hood, querying the actual supabase is very simple, we aren't doing any magic here -- it's all in the supabase library itself

https://github.com/jerryjliu/llama_index/blob/main/llama_index/vector_stores/supabase.py#L134
Maybe try the quickstart guide as a sanity check https://supabase.github.io/vecs/
ooh thank you...it actually works with the master "postgres" user, so it must be a permissions issue!
ohhh spooky! Good to know!
dropping this here for posterity:
my pgvector is installed into the "extensions" schema (which is normal)

i fixed this by running for my user "llamaindex"
Plain Text
ALTER USER llamaindex SET search_path TO "\$user", public, extensions;
GRANT USAGE ON SCHEMA extensions TO llamaindex;


thank you for the hints @Logan M !
Add a reply
Sign up and join the conversation on Discord