kawallis
10/27/2021, 3:44 AMyurix
10/27/2021, 9:55 AMchipilov
10/27/2021, 1:26 PMHarryET
10/27/2021, 1:26 PMstibbs
10/28/2021, 10:57 PMHelixen89
10/29/2021, 1:18 AMdreinon
10/29/2021, 1:55 AMdreinon
10/29/2021, 1:55 AMHelixen89
10/29/2021, 2:00 AMdreinon
10/29/2021, 2:01 AMHelixen89
10/29/2021, 2:03 AMdreinon
10/29/2021, 2:03 AMdreinon
10/29/2021, 2:04 AMHelixen89
10/29/2021, 2:04 AMHelixen89
10/29/2021, 2:04 AMHelixen89
10/29/2021, 2:05 AMHelixen89
10/29/2021, 2:11 AMdreinon
10/29/2021, 2:17 AMdreinon
10/29/2021, 2:17 AMstibbs
10/29/2021, 3:15 AMjobs
table (this is where the index should go), and a jobs_tags
table which is a mapping table containing all tags for each job.
Should I add tags into the fts
column in the jobs table? I don't think that would get the benefit of the auto updating index?garyaustin
10/29/2021, 4:13 AMstibbs
10/29/2021, 4:58 AMScott P
10/29/2021, 10:19 PMsimilarity
extension like this:
sql
SELECT * FROM wines WHERE
extensions.similarity(wines.description::TEXT, search_value) > 0.25
You can also use something like the distance operator (from the pg_trgm
extension I believe):
sql
SELECT * FROM wines WHERE
1 - (wines.description::TEXT <-> search_value) > 0.25
With enough fine tuning of the values (e.g. 0.25
), you can have something that is akin to fuzzy searching, but the specific value you should use will depend on your dataset and your own testing.
If you need something more advanced to search across multiple columns in a single function, to_tsvector
and to_tsquery
can be combined like this:
sql
SELECT * FROM wines WHERE
to_tsvector(wines.name || ' ' || wines.description || ' ' || wines.manufacturer || ' ' || wines.country) -- concat columns, but be sure to include a space to separate them!
@@ to_tsquery(search_value)
In all 3 cases, search_value
is a TEXT
parameter passed into the function.
You can of course combine any or all of the above options if you really need to using AND
/ OR
.garyaustin
10/29/2021, 10:52 PMjavi
10/30/2021, 8:31 AMchipilov
10/30/2021, 8:48 AMThomas B
10/30/2021, 12:39 PMSECURITY DEFINER SET search_path = public
thingy that I have to use when writing Functions when using Supabase, but I really do not see other tutorials or the like use.. Am I allowed to just add extensions
to it along with public, or is there any security issues with that?
I can only get pgjwt (https://github.com/michelp/pgjwt) to work with that added. 🙂
Here is the full function:
CREATE OR REPLACE FUNCTION handle_new_user() RETURNS trigger
SECURITY DEFINER SET search_path = public, extensions
AS
$$
BEGIN
INSERT INTO profiles (id, jwt)
VALUES (NEW.id, (SELECT SIGN('{
"sub": "1234567890",
"name": "John Doe"
}', 'secret')));
RETURN NEW;
END;
$$ LANGUAGE plpgsql;
dafri
10/30/2021, 3:28 PMsupabase link --url 'postgresstring'
I get the error Error: supabase_migrations.schema_migrations table conflicts with the contents of 'migrations' directory.
Any idea what I have to do in this case?HarryET
10/30/2021, 3:42 PMgaryaustin
10/30/2021, 4:03 PM