免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5344 | 回复: 3
打印 上一主题 下一主题

[原创]使用postgreSQL搭建比lucene方便N倍的全文搜索 第一部分 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-07-02 08:20 |只看该作者 |倒序浏览
[文章作者:陈臻 本文版本:v1.1 最后修改:2009.4.13 转载请注明原文链接:http://www.54chen.com/c/601 ]
所有用到到包有:
cmake-2.6.4.tar.gz (编nlpbamboo用)
CRF++-0.53.tar.gz(同上)
nlpbamboo-1.1.1.tar.bz2(分词用)
postgreSQL-8.3.3.tar.gz(索引用)
安装pgsql
tar -zxvf postgreSQL-8.3.3.tar.gz
cd postgre-8.3.3
./configure –prefix=/opt/pgsql
make
make install
useradd postgre
chown -R postgre.postgre /opt/pgsql
su - postgre
vi ~postgre/.bash_profile
添加
export PATH
PGLIB=/opt/pgsql/lib
PGDATA=/data/PGSearch
PATH=$PATH:/opt/pgsql/bin
MANPATH=$MANPATH:/opt/pgsql/man
export PGLIB PGDATA PATH MANPATH
# mkdir -p /data/PGSearch
# chown -R postgre.postgre /data/PGSearch
# chown -R postgre.postgre /opt/pgsql
#sudo -u postgre /opt/pgsql/bin/initdb –locale=zh_CN.UTF-8 –encoding=utf8 -D /data/PGSearch
#sudo -u postgre /opt/pgsql/bin/postmaster -i -D /data/PGSearch &  //允许网络访问
#sudo -u postgre /opt/pgsql/bin/createdb kxgroup
# vim /data/PGSearch/pg_hba.conf  如下增加可访问的机器:
host    all         all         10.2.19.178 255.255.255.0               trust
#su - postgre
$pg_ctl stop
$postmaster -i -D /data/PGSearch &
安装中文分词(Cmake CRF++ bamboo)
Cmake是为了编译bamboo,CRF++是bamboo依赖的。
tar -zxvf cmake-2.6.4.tar.gz
cd cmake-2.6.4
./configure
gmake
make install
tar -zxvf CRF++-0.53.tar.gz
cd CRF++-0.53
./configure
make
make install
tar -jxvf nlpbamboo-1.1.1.tar.bz2
cd nlpbamboo-1.1.1
mkdir build
cd build/
cmake .. -DCMAKE_BUILD_TYPE=release
make all
make install
cp index.tar.bz2 /opt/bamboo/
cd /opt/bamboo/
tar -jxvf index.tar.bz2
#/opt/bamboo/bin/bamboo
如果出现:
ERROR: libcrfpp.so.0: cannot open shared object file: No such file or directory
就执行:
ln -s /usr/local/lib/libcrfpp.so.* /usr/lib/
ldconfig
增加上中文分词扩展到pgsql
#vim /root/.bash_profile 也增加:
PGLIB=/opt/pgsql/lib
PGDATA=/data/PGSearch
PATH=$PATH:/opt/pgsql/bin
MANPATH=$MANPATH:/opt/pgsql/man
export PGLIB PGDATA PATH MANPATH
#source ~/.bash_profile
cd /opt/bamboo/exts/postgres/chinese_parser/
make
make install
su - postgre
cd /opt/pgsql/share/contrib/
touch /opt/pgsql/share/tsearch_data/chinese_utf8.stop
psql kxgroup
\i chinese_parser.sql 导入
再执行下面的sql,已经可以将一段话分词了:
SELECT to_tsvector(’chinesecfg’, ‘结果在命令行下执行bamboo才知道’);
先到这里,下一部分讲述对TEXT字段进行索引和查询,完整构造一整个搜索引擎。

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/cc0cc/archive/2009/07/02/4314936.aspx

论坛徽章:
0
2 [报告]
发表于 2009-07-02 09:50 |只看该作者
了解一下~~

论坛徽章:
0
3 [报告]
发表于 2010-03-12 16:49 |只看该作者
很强大,我正在作为毕设,相当的感谢能够提供如此详细的介绍

论坛徽章:
0
4 [报告]
发表于 2010-03-23 15:22 |只看该作者
请问一下在PostgreSQL8.3.3中的tsearch2安装包用重新安装一次吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP