I’ve tried using many symbols to separate columns; ||, |, &&, & with and without spaces.
For instance
JavaScript
x
3
1
.textSearch("username, title, description", "...");
2
.textSearch("username|title|description", "...");
3
And nothing has worked 🙁
Advertisement
Answer
You could create a SQL function to perform search like this:
JavaScript
1
14
14
1
create or replace function search_posts(keyword text)
2
returns setof posts
3
as
4
$func$
5
select
6
*
7
from
8
posts
9
where
10
to_tsvector(username || ' ' || title || ' ' || description) -- concat columns, but be sure to include a space to separate them!
11
@@ to_tsquery(keyword);
12
$func$
13
language sql;
14
You can call this function like this:
JavaScript
1
2
1
const {data, error} = await supabase.rpc('search_posts', { keyword: '[YOUR_SEARCH_TERM_HERE]' })
2
You can read more about textSearch here