Is there any way to search for multiple columns at...
# help
u
Is there any way to search for multiple columns at the same time in API. Sorry if this is such a fundamental question?
n
Hello @usamichizuru! This thread has been automatically created from your message in #843999948717555735 a ``few seconds ago``. Pinging @User so that they see this as well! Want to unsubscribe from this thread? Right-click the thread in Discord (or use the ... menu) and select Leave Thread to unsubscribe from future updates. Want to change the title? Use the
/title
command! We have solved your problem? Click the button below to archive it.
g
There are multiple ways to access the API. If you mean using one of the clients then the filters section in api docs is where you would start. https://supabase.com/docs/reference/javascript/using-filters You can do multiple column searches several ways as you can chain filters, or you can have multiple simple equals in a .match.
n
usamichizuru (2022-04-05)
u
No, not that kind of chaining filter, I want to make a search for example like a search bar that when client inputs, it starts to search columns for instance username and email and output the rows that matched.
thanks for helping tho.
g
Yes. You use multiple filters for that.
You can use or operation to match any column
If you want to do textsearch on multiple columns you can create a calculated column with multiple columns of text and search that also.
u
but the or operation is not like like() or ilike() operation or even textSearch() because it need a exact value in order to search
g
https://supabase.com/docs/reference/javascript/or allows you to find something in any of the columns. You could use ilike
You can use or on any of the filters, but if you do textsearch the best way is to create a new tsvector column in the data base which has all the columns text and search that.
u
Yes I know that solution which is exactly why I wonder is there a way to search multiple columns on API which is sadly no currently.
g
You can use .or(ilike...., ilike....)
u
really?
lets me try
g
You need to format all the info per postgrest format though. https://supabase.com/docs/reference/javascript/or#notes
I personally would not do full textsearch that way though for performance reasons. A couple of ilikes is probably OK. And that is not an api performance reason, just database search performance with multiple partial text columns versus just one already calculated tsvector column.
u
I see thanks for the suggestion. I am deeply appreciated. It works flawlessly and thanks for help me. 😄
*helping
g
👍 If you run into anything else start a new thread as I'm gone the rest of the day.
u
yeah thanks.
n
Thread was archived by @usamichizuru. Anyone can send a message to unarchive it.