安装测试zhparser

首先安装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’,’艾灸’)

 

 

 

 

 

 

Leave a Reply

您的电子邮箱地址不会被公开。 必填项已用 * 标注

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>