Skip to content

Commit

Permalink
implement publish time lexeme trigger. Fix tests to match results wit…
Browse files Browse the repository at this point in the history
…h counts
  • Loading branch information
reedstrm committed Dec 2, 2015
1 parent 9446606 commit 4d6cabb
Show file tree
Hide file tree
Showing 4 changed files with 7,996 additions and 14 deletions.
2 changes: 1 addition & 1 deletion cnxarchive/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def initdb(settings):
import sys
import os
import site
old_os_path = os.environ['PATH']
old_os_path = os.environ.get('PATH','')
os.environ['PATH'] = os.path.dirname(os.path.abspath('{activate_path}')) \
+ os.pathsep + old_os_path
base = os.path.dirname(os.path.dirname(os.path.abspath('{activate_path}')))
Expand Down
30 changes: 21 additions & 9 deletions cnxarchive/sql/schema/fulltext-indexing.sql
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,24 @@ CREATE TRIGGER index_fulltext_upsert
FOR EACH row
EXECUTE PROCEDURE index_fulltext_upsert_trigger();

-- CREATE OR REPLACE FUNCTION index_fulltext_lexeme_trigger()
-- RETURNS TRIGGER AS $$
-- BEGIN
--
-- INSERT into modulefti_lexemes (module_ident, lexeme, positions)
-- SELECT NEW.module_ident, substring(regex_split_to_table(NEW.module_idx::text, ' '),1,strpos(lexeme,':')-1)
-- END;
-- $$
-- LANGUAGE plpgsql;
CREATE OR REPLACE FUNCTION index_fulltext_lexeme_trigger()
RETURNS TRIGGER AS $$
BEGIN

INSERT into modulefti_lexemes (module_ident, lexeme, positions)
(with lex as (SELECT regexp_split_to_table(NEW.module_idx::text, ' ') as t )
SELECT NEW.module_ident,
substring(t,1,strpos(t,':')-1),
('{'||substring(t,strpos(t,':')+1)||'}')::int[] from lex) ;
RETURN NEW;
END;
$$
LANGUAGE plpgsql;


DROP TRIGGER IF EXISTS index_fulltext_lexeme ON modulefti;
CREATE TRIGGER index_fulltext_lexeme
BEFORE INSERT ON modulefti
FOR EACH row
EXECUTE PROCEDURE index_fulltext_lexeme_trigger();

Loading

0 comments on commit 4d6cabb

Please sign in to comment.