run-llama/LlamaIndexTS

SupabaseVectorStore lacks metadata filter support

Open

#2,008 opened on Jun 9, 2025

 (4 comments) (0 reactions) (0 assignees)TypeScript (524 forks)auto 404
buggood first issuehelp wanted

Repository metrics

Stars
 (3,078 stars)
PR merge metrics
 (PR metrics pending)

Description

Describe the bug Adding metadata filter to supabase vector store doesn't take effect.

To Reproduce Code to reproduce the behavior:

export async function chatWithLlama(workspaceId: string, userMessage: string, chatHistory: LlamaChatMessage[]) {
    Settings.embedModel = new OpenAIEmbedding();
    Settings.llm = new LlamaOpenAI({ model: process.env.LLM_MODEL! });
    const supabaseClient = createAdminClient();
    const vectorStore = new SupabaseVectorStore({
        client: supabaseClient,
        table: "document",
    });

    index = await VectorStoreIndex.fromVectorStore(vectorStore);
    const retriever = index.asRetriever({
        filters: {
            filters: [{
                key: "workspaceId",
                operator: "==",
                value: "abc"
            }]
        }
    })

    const chatEngine = index.asChatEngine({
        retriever,
        chatHistory: chatHistory,
        systemPrompt: `You are a helpful assistant that can answer questions about the documents provided. 
                       You can use the documents to answer questions. 
                       Say 'I don't know' if you can't find enough information in the provided documents.`
    });
    const response = await chatEngine.chat({ message: userMessage });
    console.log(JSON.stringify(response));
    return { response: response.message.content };
}

Expected a filter to have shown up in the logs. No filter shows up in the logs and records are not filtered as expected

create or replace function match_documents (
  match_count int,
  query_embedding vector(1536),
  filter jsonb default '{}'
)
returns table (
  id uuid,
  content text,
  metadata jsonb,
  similarity float
)
language plpgsql stable
as $$
begin
  -- This line will print the received filter 
  raise warning 'match_documents received filter: %', filter;

  return query
    select
      d.id,
      d.content,
      d.metadata,
      1 - (d.embedding <=> query_embedding) as similarity
    from document as d
    where d.metadata @> filter
    order by d.embedding <=> query_embedding
    limit match_count;
end;
$$;

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. macOS, Linux]
  • JS Runtime / Framework / Bundler (select all applicable)
  • Node.js
  • Deno
  • Bun
  • Next.js
  • ESBuild
  • Rollup
  • Webpack
  • Turbopack
  • Vite
  • Waku
  • Edge Runtime
  • AWS Lambda
  • Cloudflare Worker
  • Others (please elaborate on this)
  • Version [e.g. 22]

Additional context Add any other context about the problem here.

I would have expected filters be handled in SupabaseVectorStore, but that doesn't seem to be the case.

Contributor guide