热烈祝贺台州朗动科技的站长论坛隆重上线!(2012-05-28)    热烈庆祝伟大的祖国60周年生日 点击进来我们一起为她祝福吧(2009-09-26)    站长论坛禁止发布广告,一经发现立即删除。谢谢各位合作!.(2009-08-08)    热烈祝贺台州网址导航全面升级,全新版本上线!希望各位一如既往地支持台州网址导航的发展.(2009-03-28)    台州站长论坛恭祝各位新年快乐,牛年行大运!(2009-01-24)    台州Link正式更名为台州网址导航,专业做以台州网址为主的网址导航!(2008-05-23)    热烈祝贺台州Link资讯改名为中国站长资讯!希望在以后日子里得到大家的大力支持和帮助!(2008-04-10)    热烈祝贺台州Link论坛改名为台州站长论坛!希望大家继续支持和鼓励!(2008-04-10)    台州站长论坛原[社会琐碎]版块更名为[生活百科]版块!(2007-09-05)    特此通知:新台州站长论坛的数据信息全部升级成功!">特此通知:新台州站长论坛的数据信息全部升级成功!(2007-09-01)    台州站长论坛对未通过验证的会员进行合理的清除,请您谅解(2007-08-30)    台州网址导航|上网导航诚邀世界各地的网站友情链接和友谊联盟,共同引领网站导航、前进!(2007-08-30)    禁止发广告之类的帖,已发现立即删除!(2007-08-30)    希望各位上传与下载有用资源和最新信息(2007-08-30)    热烈祝贺台州站长论坛全面升级成功,全新上线!(2007-08-30)    
便民网址导航,轻松网上冲浪。
台州维博网络专业开发网站门户平台系统
您当前的位置: 首页 » MySQL/MSSQL编程 » 初试MYSQL全文检索工具——Sphinx

初试MYSQL全文检索工具——Sphinx

论坛链接
  • 初试MYSQL全文检索工具——Sphinx
  • 发布时间:2008-11-05 10:26:43    浏览数:6959    发布者:tznktg    设置字体【   
参考文章:
用 PHP 构建自定义搜索引擎
Sphinx速成指南

测试环境


操作系统:windows xp
数据库版本:MYSQL Server version 5.0.45




一、安装
详细安装过程参考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.
TAG: mysql MySQL Mysql Sphinx 检索工具 MYSQL 全文 初试
娱乐休闲专区A 影视预告B 音乐咖啡C 英语阶梯D 生活百科
网页编程专区E AMPZF HTMLG CSSH JSI ASPJ PHPK JSPL MySQLM AJAX
Linux技术区 N 系统管理O 服务器架设P 网络/硬件Q 编程序开发R 内核/嵌入
管理中心专区S 发布网址T 版主议事U 事务处理