PostgreSQL 全文索引

-- 添加全文索引字段并且建立触发器
-- alter table keyword add COLUMN tsv tsvector;

-- create or replace function keyword_ts_trigger_function() returns trigger as $$
-- begin
--     new.keyword_participle := to_tsvector('english_nostop',COALESCE(new.keyword,'') );
--     return new;
--    end
--    $$ language plpgsql;
-- 
--     create trigger messages_ts_trigger
--         before insert 
--         on keyword
--         for each row
--         execute procedure keyword_ts_trigger_function();
-- 创建索引
-- CREATE INDEX keyword_full_text_index on keyword 
-- using gin(to_tsvector('english_nostop',keyword));
-- 更新刚刚创建的字段
--

参考文章:

https://stackoverflow.com/questions/1497895/can-i-configure-stop-words-programmatically-with-postgresql-full-text-search

https://www.youtube.com/watch?v=LS6kF43DEt8

猜你喜欢

转载自www.cnblogs.com/ryanzheng/p/9105773.html