[root@prod /opt]# tar -jxvf nlpbamboo-1.1.2.tar.bz2
[root@prod /opt/nlpbamboo-1.1.2]# cd nlpbamboo-1.1.2
[root@prod /opt/nlpbamboo-1.1.2/build]# cd build/
[root@prod /opt/nlpbamboo-1.1.2/build]# cmake .. -DCMAKE_BUILD_TYPE=release
[root@prod /opt/nlpbamboo-1.1.2/build]# gmake all
[root@prod /opt/nlpbamboo-1.1.2/build]# gmake install
5.加入lib库链接
[root@prod /opt/nlpbamboo-1.1.2/build]# echo "/usr/lib" >>/etc/ld.so.conf
[root@prod /opt/nlpbamboo-1.1.2/build]# echo "/usr/local/lib" >>/etc/ld.so.conf
[root@prod /opt/nlpbamboo-1.1.2/build]# ldconfig -f /etc/ld.so.conf
测试是否正常:
[root@prod /opt/nlpbamboo-1.1.2/build]# ldconfig -p|grep bambo
libbamboo.so.2 (libc6,x86-64) => /usr/lib/libbamboo.so.2
libbamboo.so (libc6,x86-64) => /usr/lib/libbamboo.so
[root@prod /opt/nlpbamboo-1.1.2/build]# ldconfig -p|grep crf
libcrfpp.so.0 (libc6,x86-64) => /usr/local/lib/libcrfpp.so.0
libcrfpp.so (libc6,x86-64) => /usr/local/lib/libcrfpp.so
6.加入索引:[root@prod /opt/nlpbamboo-1.1.2/build]# cd /opt/bamboo
wget http : //nlpbamboo.googlecode.com/files/index.tar.bz2
完蛋这里又下载不了了,还是别人帮忙下载的,附件有。
[root@prod /opt]# cd bamboo/
[root@prod /opt/bamboo]# tar -jxvf index.tar.bz2
[root@prod /opt/bamboo]# cd exts/postgres/chinese_parser/
[root@prod /opt/bamboo/exts/postgres/chinese_parser]# make
[root@prod /opt/bamboo/exts/postgres/chinese_parser]# make install
7.编辑PG支持模块
[postgres@prod /opt/pgsql/share/contrib]$ cd /opt/bamboo/exts/postgres/chinese_parser
[postgres@prod /opt/pgsql/share/contrib]$make
[postgres@prod /opt/pgsql/share/contrib]$make install
[root@prod /opt/bamboo/exts/postgres/chinese_parser]# touch $PGHOME/share/tsearch_data/chinese_utf8.stop
[root@prod /opt/bamboo/exts/postgres/chinese_parser]# cd /opt/bamboo/exts/postgres/pg_tokenize
[root@prod /opt/bamboo/exts/postgres/chinese_parser]# make[root@prod /opt/bamboo/exts/postgres/chinese_parser]# make install
8.安装PG支持模块
[root@prod /opt/bamboo/exts/postgres/chinese_parser]# su postgres
[postgres@prod /opt/bamboo/exts/postgres/chinese_parser]$ cd /opt/pgsql/share/contrib/
[postgres@prod /opt/pgsql/share/contrib]$ psql -h 127.0.0.1 postgres postgres -f chinese_parser.sql
[postgres@prod /opt/pgsql/share/contrib]$ psql -h 127.0.0.1 postgres postgres -f pg_tokenize.sql中间可能会遇到这种错误:
postgres=# select * from tokenize('你好我是中国人');
ERROR: invalid byte sequence for encoding "UTF8": 0xc4 0xe3
ERROR: invalid byte sequence for encoding "UTF8": 0xc4 0xe3
原因是没有正确设置客户端字符集。解决方法:
9.查看全文检索配置中加入了chinesecfg的配置
postgres=# select * from tpg_ts_config;
cfgname | cfgnamespace | cfgowner | cfgparser
------------+--------------+----------+-----------
simple | 11 | 10 | 3722
danish | 11 | 10 | 3722
dutch | 11 | 10 | 3722
english | 11 | 10 | 3722
finnish | 11 | 10 | 3722
french | 11 | 10 | 3722
german | 11 | 10 | 3722
hungarian | 11 | 10 | 3722
italian | 11 | 10 | 3722
norwegian | 11 | 10 | 3722
portuguese | 11 | 10 | 3722
romanian | 11 | 10 | 3722
russian | 11 | 10 | 3722
spanish | 11 | 10 | 3722
swedish | 11 | 10 | 3722
turkish | 11 | 10 | 3722
chinesecfg | 11 | 10 | 16453
(17 rows)
测试:postgres=# select * from to_tsvector('chinesecfg','你好,我是中国人. 前在杭州斯凯做数据库相关的ぷ'); to_tsvector ------------------------------------------------------------------------------------------------------- ',':2 '.':7,17 '中国':5 '人':6 '你好':1 '做':12 '在':9 '工作':16 '我':3 '数据库':13 '斯凯':11 '是':4 '杭州':10 '的':15 '目前':8 '相关':14 (1 row)
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25954236/viewspace-1809299/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/25954236/viewspace-1809299/