This commit is contained in:
@@ -155,7 +155,7 @@ namespace AyaNova.Util
|
||||
|
||||
|
||||
//SEARCH TABLES
|
||||
|
||||
|
||||
await ExecQueryAsync("CREATE TABLE asearchdictionary (id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY, word varchar(255) not null)");
|
||||
//Must be unique and also this is hit a *lot* during searches and also indexing
|
||||
await ExecQueryAsync("CREATE UNIQUE INDEX asearchdictionary_word_idx ON asearchdictionary (word);");
|
||||
@@ -173,7 +173,36 @@ namespace AyaNova.Util
|
||||
await ExecQueryAsync("CREATE INDEX asearchkey_wordid_otype_idx ON asearchkey (wordid, objecttype);");
|
||||
|
||||
//Search indexing stored procedure
|
||||
await ExecQueryAsync(@"CREATE OR REPLACE PROCEDURE public.aydosearchindex(
|
||||
// await ExecQueryAsync(@"CREATE OR REPLACE PROCEDURE public.aydosearchindex(
|
||||
// wordlist text[],
|
||||
// ayobjectid bigint,
|
||||
// ayobjecttype integer)
|
||||
// LANGUAGE 'plpgsql'
|
||||
|
||||
// AS $BODY$DECLARE
|
||||
// s text;
|
||||
// wordid bigint;
|
||||
// BEGIN
|
||||
// IF ayobjectid=0 THEN
|
||||
// RAISE EXCEPTION 'Bad object id --> %', ayobjectid;
|
||||
// END IF;
|
||||
|
||||
// IF ayobjecttype=0 THEN
|
||||
// RAISE EXCEPTION 'Bad object type --> %', ayobjecttype;
|
||||
// END IF;
|
||||
|
||||
|
||||
// delete from asearchkey where objectid=ayobjectid and objecttype=ayobjecttype;
|
||||
|
||||
// FOREACH s IN ARRAY wordlist
|
||||
// LOOP
|
||||
// insert into asearchdictionary (word) values(s) on conflict (word) do update set word=excluded.word returning id into wordid;
|
||||
// insert into asearchkey (wordid,objectid,objecttype) values(wordid,ayobjectid,ayobjecttype);
|
||||
// END LOOP;
|
||||
// END;
|
||||
// $BODY$;");
|
||||
|
||||
await ExecQueryAsync(@"CREATE OR REPLACE PROCEDURE public.aydosearchindex(
|
||||
wordlist text[],
|
||||
ayobjectid bigint,
|
||||
ayobjecttype integer)
|
||||
@@ -196,7 +225,8 @@ delete from asearchkey where objectid=ayobjectid and objecttype=ayobjecttype;
|
||||
|
||||
FOREACH s IN ARRAY wordlist
|
||||
LOOP
|
||||
insert into asearchdictionary (word) values(s) on conflict (word) do update set word=excluded.word returning id into wordid;
|
||||
insert into asearchdictionary (word) values(s) on conflict (word) do nothing;
|
||||
SELECT id INTO STRICT wordid FROM asearchdictionary WHERE word = s;
|
||||
insert into asearchkey (wordid,objectid,objecttype) values(wordid,ayobjectid,ayobjecttype);
|
||||
END LOOP;
|
||||
END;
|
||||
|
||||
Reference in New Issue
Block a user