langchainjs: SupabaseFilterRPCCall does not work, Error: PGRST202 Could not find the function public.match_documents(query_embedding)
Related doc: https://js.langchain.com/docs/modules/indexes/vector_stores/integrations/supabase
Correct
const vectorStore = await SupabaseVectorStore.fromExistingIndex(new OpenAIEmbeddings(), {
client: supabaseClient,
// https://js.langchain.com/docs/modules/indexes/vector_stores/integrations/supabase
filter: { source: videoUrl },
})
Incorrect
After migrating to use SupabaseFilterRPCCall, failed:
const funcFilterByCollection: SupabaseFilterRPCCall = (rpc) =>
// rpc.filter('metadata->>source', 'in', `(${contentUrls.join(',')})`)
rpc.filter('metadata->>source', 'eq', videoUrl)
const embeddings = new OpenAIEmbeddings()
const vectorStore = new SupabaseVectorStore(embeddings, {
client: supabaseClient,
tableName: 'documents',
filter: funcFilterByCollection
})
Error message
- error node_modules/langchain/dist/vectorstores/supabase.js (79:18) @ SupabaseVectorStore.similaritySearchVectorWithScore
- error Error searching for documents: PGRST202 Could not find the function public.match_documents(query_embedding) in the schema cache Searched for the function public.match_documents with parameter query_embedding or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache.
Error searching for documents: PGRST202 Could not find the function public.match_documents(query_embedding) in the schema cache Searched for the function public.match_documents with parameter query_embedding or with a single unnamed json/jsonb parameter, but no matches were found in the schema cache.
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 18 (3 by maintainers)
Thank you, I had a similar problem and fixed it by dropping and recreating the function per the latest docs
@JimmyLv Have you solved this problem? if not, can DM me. BTW, love your BilbiGPT.
@hwchase17 @supabase any idea? 😁
It still doesn’t work, I’m pretty sure I definitely have this match_documents function and I’m able to get it to work through the REST API.
Answer generated by a 🤖
Answer
The error message “PGRST202 Could not find the function public.match_documents(query_embedding)” indicates that the function
match_documentsis not found in your database schema. This function is required for theSupabaseVectorStoreto perform similarity searches.The
match_documentsfunction is expected to be present in your database as it is used for similarity search in theSupabaseVectorStoreclass. If the function does not exist, you need to create it. The function should take a query embedding and return the matched documents. The exact implementation of the function depends on your specific use case and database structure.In your incorrect code, the
queryNameparameter is not specified when creating theSupabaseVectorStore. This could be the reason why thematch_documentsfunction is not found. To fix this issue, you should specify thequeryNameparameter when creating theSupabaseVectorStore:Please ensure that the
match_documentsfunction exists in your Supabase database and is accessible by the client. If the function is present but still not found, make sure that it’s in the correct schema and that the schema is included in the search path. Also, ensure that the function accepts the correct parameters. The error message suggests that the function should either accept a parameter namedquery_embeddingor a single unnamed json/jsonb parameter.If the error persists, you should check your Supabase database to ensure that the
match_documentsfunction exists and is correctly defined. If you have a different function name in your database, you should provide it while creating an instance ofSupabaseHybridSearchSources
This response is meant to be useful, save you time, and share context. It is not meant to be a precise solution, but rather a starting point for your own research.
Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.
I’ve tried adding
queryNamebut it still doesn’t work