Multiple entries in supabase vector store metadata filter

Hello everyone, I’m currently working on a RAG cha where users can access a set of meetings, and I need to filter the available meetings based on the meeting_ids that the user has access to. Here’s the scenario:

i have a vector store with the my metadata looking like this:

{ meeting_id: "id1", other_fields: "blah"}

Each user has a list of meeting_ids that define which meetings they have access to. These meeting_ids are hard-coded as of now, just to test.

When filtering the meetings that a user can view, I need to ensure that only those meetings the user has access to are shown. For a single meeting, the filter works as expected — i.e., filtering by one meeting_id works fine.

The issue arises when a user has access to multiple meetings. The system fails to filter properly when there are multiple meeting_ids. Specifically, when I try to pass a list of meeting_ids or a comma-separated string (e.g., “meeting1,meeting2” ), the filter does not work as expected.

I want the filter to correctly handle multiple meeting IDs so that the user can only view the meetings they have access to, regardless of how many meetings they are authorized for.

As far as i can see, there is no documented use for filtering by multiple values.
It’d be nice to see if we could do something like value in list_of_values on the metadata filter.

  • n8n version: 1.63.4
  • Database : Supabase
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via: n8n cloud
  • Operating system: Linux

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

Hi @Pranav,

Unfortunately, it’s not yet possible to use more advanced filtering with the Supabse node.
BUT, you can modify the matching function in your Supabase database to split passed metadata filter values(using ‘,’) to get this behavior.

The matching function would look like this:

#variable_conflict use_column
begin
  return query
  with filter_key as (
    select jsonb_object_keys(filter) as key limit 1
  )
  select
    id,
    content,
    metadata,
    1 - (documents.embedding <=> query_embedding) as similarity
  from documents, filter_key
  where trim(metadata->>filter_key.key) = any(
    select trim(value)
    from unnest(
      string_to_array(
        trim(both '"' from (filter->>filter_key.key)), 
        ','
      )
    ) as value
  )
  order by documents.embedding <=> query_embedding
  limit match_count;
end;

You can find it in your Supabase dashboard in “Database” → “Functions” and look for “match_documents” or however you called it when creating the embeddings table.

Using this matching function I’m able to use multiple values to retrieve similar documents:

2 Likes

Thank you so much. This works :+1:

1 Like