N8n: Case-Insensitive Fuzzy Search Not Working in Supabase & Postgres Tools

Hey everyone,

I’m working on an n8n workflow that needs to search contacts in Supabase using fuzzy matching and case-insensitive queries. Since I’m not native speaker nor code savvy I’ve used chatgtp to construct what I’m facing. Here’s what I’ve tried so far:

:mag: What I’m Trying to Achieve

  • Lookup contact names in Supabase (fuzzy & case-insensitive).
  • Handle typos & partial matches (e.g., "John" should match "B.John" or "b.john").
  • Minimize token usage in OpenAI by returning only 1 best match instead of all results. (I have about 140 rows of employee contacts)

:hammer_and_wrench: What I’ve Tried & Issues Faced

:one: Supabase Tool in n8n

  • :white_check_mark: **I can select the column with dropdown menu
  • :white_check_mark: I can set the value to “Defined automatically by the model → Works but is case-sensitive. :x:
  • :x: When using “Expression,” I don’t know the correct placeholder for fuzzy search (ILIKE).

:two: HTTP Request Tool (Query Parameters)

  • :white_check_mark: I tried using ILIKE as a query parameter,
json

{
“name”: “ilike.Urangoo”
}

  • :x: Still case-sensitive.
  • :x: Couldn’t find the correct placeholder syntax for passing variables dynamically.

:three: Postgres Tool in n8n (Current Working Solution)

  • :white_check_mark: **Lets me select the column from dropdown.

  • :white_check_mark: “Defined automatically by the model” works & saves tokens by limiting results.

  • :x: Still case-sensitive & fuzzy search (ILIKE, pg_trgm) isn’t working correctly.

  • :x: Tried adding search_vector (tsvector) in SQL Editor, but can’t get it working in n8n.

:pushpin: SQL Queries I Tried (Worked in Supabase, Not in n8n)

I tested case-insensitive fuzzy search in Supabase SQL Editor, and it works, but I don’t know the correct placeholder to pass it in n8n.

SELECT * FROM contacts  
WHERE LOWER(name) ILIKE LOWER('%John%')  
ORDER BY similarity(name, 'John') DESC  
LIMIT 1;

:white_check_mark: This works in SQL Editor but not in n8n.

:rocket: What I Need Help With

:one: What is the correct placeholder for passing a variable dynamically in n8n’s Supabase/Postgres Tool?
:two: How can I make case-insensitive fuzzy search work inside n8n using Postgres Tool or HTTP Request Tool?
:three: Does search_vector (tsvector) help here? If so, how do I properly integrate it with n8n?

==================================================
n8n Version: 1.78.1 (Self-Hosted)
Database: Likely PostgreSQL (since I’m using Supabase), but I’m not 100% sure.
n8n EXECUTIONS_PROCESS: Default (probably own).
Running n8n via: Self-hosted on AWS Free Tier (Ubuntu 22.04).
Installation Method: Docker**.
Operating System: Ubuntu (AWS Free Tier).

I would try use the “like” operator not equals for email compare, as well I would try enable “Tool Description” to be manual, and add detailed explanation on how to “fuzzy” search with using the “%” wildcard operator. This may need to be done on the agent level as well.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.