My favorites | Sign in
Project Logo
                
Search
for
Updated Sep 21, 2009 by jianingy.yang
Labels: Phase-Deploy, Featured, Phase-Implementation
TSearch2  
编译和安装PostgreSQL扩展和TSearch2扩展

PostgreSQL 分词函数(不需要TSearch2支持)

PostgreSQL分词函数需要安装好Bamboo的系统(不需要Bamboo源代码)。 如果您的系统中没有安装Bamboo,请参考:

编译和安装

$ cd /opt/bamboo/exts/postgresql/tokenize
$ make
$ sudo make install

创建分词函数

$ psql
postgres=# \i /usr/local/pgsql/share/contrib/pg_tokenize.sql

确保配置文件正确

请确保/etc/bamboo.cfg或者/opt/etc/bamboo.cfg存在并正确配置。

测试

postgres=# select tokenize('中文分词');
 tokenize  
------------
 中文 分词 
(1 row)

Tsearch2 分词模块

Tsearch2分词模块需要安装好Bamboo的系统以及Bamboo源代码。安装Bamboo请参考HowToBuild

编译和安装

$ cd /opt/bamboo/exts/postgresql/chinese_parser
$ make
$ make install

创建分词模块

$ psql
postgres=# \i /usr/local/pgsql/share/contrib/chinese_parser.sql

测试

postgres=# SELECT to_tsvector('chinesecfg', '我爱北京天安门');
            to_tsvector            
-----------------------------------
 '我':1 '爱':2 '北京':3 '天安门':4
(1 row)

Comment by holyful, Nov 24, 2008

$ psql postgres=# \i /usr/local/pgsql/share/contrib/chinese_parser.sql

来到这步的时候

psql:/usr/local/postgresql/share/contrib/chinese_parser.sql:39: ERROR: could not open stop-word file "/usr/local/postgresql/share/tsearch_data/chinese_utf8.stop": 没有那个文件或目录

我应该如何制作 chinese_utf8.stop ?谢谢

Comment by detrox, Dec 05, 2008

如果没有特殊需要,chinese_utf8.stop做一个空的就可以。

Comment by longying23, Jan 20, 2009

请问Tsearch2 分词模块适用于那个版本,pg8.3以前的可以吗

Comment by malcolmyam, Sep 09, 2009

无法执行 $ cd /opt/bamboo/exts/postgresql/bamboo $ make $ sudo make install 需要帮助


Sign in to add a comment
Hosted by Google Code