Skip to content

Commit

Permalink
fix unaccent search
Browse files Browse the repository at this point in the history
  • Loading branch information
maltaesousa committed Mar 30, 2021
1 parent b7b834d commit 59f37a9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions scripts/triggers.sql
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
CREATE TEXT SEARCH CONFIGURATION fr ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION fr
ALTER MAPPING FOR hword, hword_part, word
WITH unaccent, french_stem;

CREATE FUNCTION geoshop.update_product_tsvector()
RETURNS trigger
LANGUAGE 'plpgsql'
COST 100
VOLATILE NOT LEAKPROOF
AS $BODY$
BEGIN
NEW.ts := to_tsvector('french', NEW.label || ' ' || (
NEW.ts := to_tsvector('fr', NEW.label || ' ' || (
SELECT concat(description_long, ' ' , description_short) FROM geoshop.metadata WHERE id = NEW.metadata_id
));
RETURN NEW;
Expand All @@ -20,7 +25,7 @@ CREATE FUNCTION geoshop.update_metadata_tsvector()
AS $BODY$
BEGIN
UPDATE geoshop.product p
SET ts = to_tsvector('french', label || ' ' || concat(NEW.description_long, ' ' , NEW.description_short))
SET ts = to_tsvector('fr', label || ' ' || concat(NEW.description_long, ' ' , NEW.description_short))
WHERE NEW.id = p.metadata_id;
RETURN NEW;
END;
Expand Down

0 comments on commit 59f37a9

Please sign in to comment.