Skip to content

Commit

Permalink
Merge pull request #1037 from julep-ai/x/openai-embed
Browse files Browse the repository at this point in the history
fix: Add safety clause to text seaerch altering query
  • Loading branch information
whiterabbit1983 authored Jan 9, 2025
2 parents ad24128 + 3d919fc commit 30bfff9
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions memory-store/migrations/000006_docs.up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -122,22 +122,27 @@ DO $$
DECLARE
lang text;
BEGIN
FOR lang IN (SELECT cfgname FROM pg_ts_config WHERE cfgname IN (
'arabic', 'danish', 'dutch', 'english', 'finnish', 'french',
'german', 'greek', 'hungarian', 'indonesian', 'irish', 'italian',
'lithuanian', 'nepali', 'norwegian', 'portuguese', 'romanian',
'russian', 'spanish', 'swedish', 'tamil', 'turkish'
))
LOOP
-- Configure integer dictionary
EXECUTE format('ALTER TEXT SEARCH CONFIGURATION %I
ALTER MAPPING FOR int, uint WITH intdict', lang);

-- Configure synonym and stemming
EXECUTE format('ALTER TEXT SEARCH CONFIGURATION %I
ALTER MAPPING FOR asciihword, hword_asciipart, hword, hword_part, word, asciiword
WITH xsyn, %I_stem', lang, lang);
END LOOP;
BEGIN
FOR lang IN (SELECT cfgname FROM pg_ts_config WHERE cfgname IN (
'arabic', 'danish', 'dutch', 'english', 'finnish', 'french',
'german', 'greek', 'hungarian', 'indonesian', 'irish', 'italian',
'lithuanian', 'nepali', 'norwegian', 'portuguese', 'romanian',
'russian', 'spanish', 'swedish', 'tamil', 'turkish'
))
LOOP
-- Configure integer dictionary
EXECUTE format('ALTER TEXT SEARCH CONFIGURATION %I
ALTER MAPPING FOR int, uint WITH intdict', lang);

-- Configure synonym and stemming
EXECUTE format('ALTER TEXT SEARCH CONFIGURATION %I
ALTER MAPPING FOR asciihword, hword_asciipart, hword, hword_part, word, asciiword
WITH xsyn, %I_stem', lang, lang);
END LOOP;
EXCEPTION
WHEN others THEN
RAISE NOTICE 'An error occurred during altering search configurations: %, %', SQLSTATE, SQLERRM;
END;
END
$$;

Expand Down

0 comments on commit 30bfff9

Please sign in to comment.