mysql 全文搜索软件_初试MYSQL全文检索工具——Sphinx

参考文章:

用 PHP 构建自定义搜索引擎

Sphinx速成指南

测试环境

操作系统:windows xp

数据库版本:MYSQL Server version          5.0.45

anchor.gif

一、安装

详细安装过程参考Sphinx速成指南

二、测试sphinx自带的demo。

1、导入数据库文件example.sql。

该文件在test数据库新建立一个documents,并插入基本的测试数据。

2、修改sphinx.conf.in文件的配置参数,并保存为sphinx.conf文件。

主要修改以下几个参数

第一、连接数据库的用户名和密码

sql_user        = root

sql_pass        = ***** #你自己的密码

第二、索引路径

path      = E:/web/sphinx/data/test1#改为自己的路径

3、建立索引

bin/indexer.exe是建立索引的程序,具体参数可以在命令行下查看帮助。

E:"web"sphinx>bin"indexer --config sphinx.conf test1

Sphinx 0.9.8-release (r1371)

Copyright (c) 2001-2008, Andrew Aksyonoff

using config file 'sphinx.conf'...

indexing index 'test1'...

collected 4 docs, 0.0 MB

sorted 0.0 Mhits, 100.0% done

total 4 docs, 193 bytes

total 0.127 sec, 1521.85 bytes/sec, 31.54 docs/sec

4、开启查询的守护进程

E:"web"sphinx>bin"searchd --config sphinx.conf

Sphinx 0.9.8-release (r1371)

Copyright (c) 2001-2008, Andrew Aksyonoff

WARNING: forcing --console mode on Windows

using config file 'sphinx.conf'...

WARNING: index 'test1stemmed': preload: failed to open @CONFDIR@/data/test1stemm

ed.sph: No such file or directory; NOT SERVING

WARNING: index 'dist1': no such local index 'test1stemmed' - SKIPPING LOCAL INDE

X

creating server socket on 0.0.0.0:3312

accepting connections

注意开启3312端口,并修改相应的参数

5、查询测试。

查询了两次,分别是ggart和another。结合数据库查看,结果是正确的。

E:"web"sphinx>bin"search -c sphinx.conf ggart

Sphinx 0.9.8-release (r1371)

Copyright (c) 2001-2008, Andrew Aksyonoff

using config file 'sphinx.conf'...

index 'test1': query 'ggart ': returned 0 matches of 0 total in 0.000 sec

words:

1. 'ggart': 0 documents, 0 hits

index 'test1stemmed': search error: failed to open @CONFDIR@/data/test1stemmed.s

ph: No such file or directory.

E:"web"sphinx>bin"search -c sphinx.conf another

Sphinx 0.9.8-release (r1371)

Copyright (c) 2001-2008, Andrew Aksyonoff

using config file 'sphinx.conf'...

index 'test1': query 'another ': returned 1 matches of 1 total in 0.000 sec

displaying matches:

1. document=3, weight=2, group_id=2, date_added=Tue Aug 05 17:22:06 2008

id=3

group_id=2

group_id2=7

date_added=2008-08-05 17:22:06

title=another doc

content=this is another group

words:

1. 'another': 1 documents, 2 hits

index 'test1stemmed': search error: failed to open @CONFDIR@/data/test1stemmed.s

ph: No such file or directory.

下一步测试sphinx的中文全文检索和PHP程序的结合!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值