My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
TSearch2  
编译和安装PostgreSQL扩展和TSearch2扩展
Phase-Deploy, Featured, Phase-Implementation
Updated Apr 8, 2010 by laserhe...@gmail.com

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

PostgreSQL分词函数需要安装好Bamboo的系统(不需要Bamboo源代码)和预先安装好的postgresql,编译环境需要能找到 pg_config 命令。 如果您的系统中没有安装Bamboo,请参考:

编译和安装

$ cd /opt/bamboo/exts/postgresql/pg_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请参考GettingStarted

编译和安装

$ 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 holy...@gmail.com, 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 det...@gmail.com, Dec 5, 2008

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

Comment by longyin...@gmail.com, Jan 20, 2009

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

Comment by malcolm...@gmail.com, Sep 9, 2009

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

Comment by doke...@gmail.com, Mar 19, 2010

因为你没有将GLIB等一些资料加入到系统里面,详情请见别人的链接http://bbs2.chinaunix.net/viewthread.php?tid=1496155

Comment by jhaoc...@gmail.com, Oct 26, 2010

发现 chinese_utf8.stop 的第一行无效。加个回车就行了。


Sign in to add a comment
Powered by Google Project Hosting