Category: Supabase and databases

pgvector HNSW: filter search returns too few results

Read this guide in Polish

The tenant id filter used limits the number of results returned below the expected limit.

How to identify the source of the problem

Compare the result when searching accurately with the approximate HNSW index and tenant id filter.

Compare the result for the authorized and unauthorised user, project name and exact error code.

Repair steps

Customize search parameters or index strategy according to filter selectivity.

How to Test Solution

The comparative test measures recall and does not reveal vectors of other tenants.

Security and restrictions

Change permissions and scheme first on test data with backup. Do not put service role in your browser.