Full text search in python
Hi!
I am wondering if there is a way to do the full text search as described here? https://supabase.com/docs/guides/database/full-text-search?language=js&example-view=sql
Note I am fine on creating the fts column in the table I am searching, just when I am trying to do the actual search.
Note I am trying to use this: initial_query = initial_query.filter('fts', 'plfts', keyword_query)
Where the keyword_query is either one word or a few strung together by |
If I attempt the same query in the sql in supabase itself it works, but it doesnt work if I try and use .filter and I am not sure what else to use (eg textsearch does not exist on it).
How can I get this to work?
I have considered:
- Perhaps there is a different way to format it so I get the actual results here that i have just missed
- Perhaps there is a way to send the sql statement directly? (this is in python so all in the back end)
Unsure how to get this to work
Thanks in advance!
You would perform a full text search using the .text_search method.
client.table("movies").select("*").text_search("title", "'The Aveng'").execute()
or if you want to manually use a filter you can do
client.table("movies").select("*").filter("title", "fts", "'The Aveng'").execute()
Do note the single quote around 'The Aveng' as it is necessary for the full text search to work. Also in your example you have the order incorrect, its column_name, operator and criteria that the .filter function takes.
This has now been documented in the reference docs https://supabase.com/docs/reference/python/textsearch