查看: 6836|回复: 0
打印 上一主题 下一主题

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

[复制链接]
跳转到指定楼层
1#
发表于 2008-11-5 10:26:43 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
参考文章:
用 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 全文 初试
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表