简体   繁体   中英

How do you perform a full text search via the Supabase Rest API?

Please can someone help provide the correct syntax for the request when making the full-text search query when making a REST API request?

I've been looking at the Supabase docs, and I'm sure you can perform full-text searches generally: https://supabase.com/docs/guides/database/full-text-search https://supabase.com/docs/reference/javascript/textsearch

However I'd like to perform the search by using the REST API. Here are a few examples of things I've tried so far:

  1. https://apikey.supabase.co/rest/v1/table?field=textSearch.%28"query"%29
  2. https://apikey.supabase.co/rest/v1/table?field=to_tsquery.%28"query"%29
  3. https://apikey.supabase.co/rest/v1/table?select=*&to_tsquery=field.query
  4. https://apikey.supabase.co/rest/v1/table?select=*&to_tsquery=field.query

PS I also attempted to use this type of format: https://github.com/supabase/supabase/discussions/1069

Any help would be much appreciated, thanks!

Supabase uses postgREST for their REST API. You can check the postgREST documentation for this feature.

The fts filter has a number of options to support flexible textual queries, namely the choice of plain vs phrase search and the language used for stemming. Suppose that tsearch is a table with column my_tsv, of type tsvector. The following examples illustrate some possibilities:

GET /tsearch?my_tsv=fts(french).amusant HTTP/1.1

GET /tsearch?my_tsv=plfts.The%20Fat%20Cats HTTP/1.1

GET /tsearch?my_tsv=not.phfts(english).The%20Fat%20Cats HTTP/1.1
Operator Meaning
fts Full-Text Search using to_tsquery
plfts Full-Text Search using plainto_tsquery
phfts Full-Text Search using phraseto_tsquery
wfts Full-Text Search using websearch_to_tsquery

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM