首先安装SCWS,网上说明有些问题,直接下载后解压,
./configure ; make install
下载zhparser源码:
git clone https://github.com/amutu/zhparser.git
然后编译的时候,因为Postgresql版本安装有点混乱,出现错误,直接安装相关库
sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common
然后编译成功
make && make install
配置zhparser
CREATE EXTENSION zhparser;
CREATE TEXT SEARCH CONFIGURATION testzhcfg (PARSER = zhparser);
ALTER TEXT SEARCH CONFIGURATION testzhcfg ADD MAPPING FOR n,v,a,i,e,l WITH simple;
建立全文检索的索引
create index idx_gin_content on content using gin(to_tsvector(‘testzhcfg’,content));
通过建立了索引(gin)的全文检索搜索数据库记录
select * from content where to_tsvector(‘testzhcfg’,content) @@ to_tsquery(‘testzhcfg’,’艾灸’)