博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
第 11 章 Sphinx
阅读量:6083 次
发布时间:2019-06-20

本文共 2756 字,大约阅读时间需要 9 分钟。

http://sphinxsearch.com/

sudo apt-get install sphinxsearch

/etc/sphinxsearch/sphinx.conf

sudo cp /etc/sphinxsearch/sphinx-min.conf.dist /etc/sphinxsearch/sphinx.conf

创建测试数据库并导入测试数据

$ wget http://sphinxsearch.googlecode.com/svn/trunk/example.sql$ mysql -h localhost -uroot -p < example.sql$ mysql -h localhost -uroot -pCREATE USER 'test'@'localhost' IDENTIFIED BY  '';GRANT SELECT ON test.* TO 'test'@'localhost';FLUSH PRIVILEGES;mysql> quit$ echo "select * from documents" | mysql -utest -p testEnter password:id      group_id        group_id2       date_added      title   content1       1       5       2011-02-12 15:29:34     test one        this is my test document number one. also checking search within phrases.2       1       6       2011-02-12 15:29:34     test two        this is my test document number two3       2       7       2011-02-12 15:29:34     another doc     this is another group4       2       8       2011-02-12 15:29:34     doc number four this is to test groups

创建索引

sudo indexer <index>

$ sudo indexer test1Sphinx 0.9.8.1-release (r1533)Copyright (c) 2001-2008, Andrew Aksyonoffusing config file '/etc/sphinxsearch/sphinx.conf'...indexing index 'test1'...collected 4 docs, 0.0 MBsorted 0.0 Mhits, 100.0% donetotal 4 docs, 193 bytestotal 0.012 sec, 16531.05 bytes/sec, 342.61 docs/sec
$ sudo /etc/init.d/sphinxsearch startStarting sphinx: Sphinx 0.9.8.1-release (r1533)Copyright (c) 2001-2008, Andrew Aksyonoffusing config file '/etc/sphinxsearch/sphinx.conf'...creating server socket on 0.0.0.0:3312sphinx.

测试

search "keyword"

$ search testSphinx 0.9.8.1-release (r1533)Copyright (c) 2001-2008, Andrew Aksyonoffusing config file '/etc/sphinxsearch/sphinx.conf'...index 'test1': query 'test ': returned 3 matches of 3 total in 0.000 secdisplaying matches:1. document=1, weight=2, group_id=1, date_added=Sat Feb 12 15:29:34 2011        id=1        group_id=1        group_id2=5        date_added=2011-02-12 15:29:34        title=test one        content=this is my test document number one. also checking search within phrases.2. document=2, weight=2, group_id=1, date_added=Sat Feb 12 15:29:34 2011        id=2        group_id=1        group_id2=6        date_added=2011-02-12 15:29:34        title=test two        content=this is my test document number two3. document=4, weight=1, group_id=2, date_added=Sat Feb 12 15:29:34 2011        id=4        group_id=2        group_id2=8        date_added=2011-02-12 15:29:34        title=doc number four        content=this is to test groupswords:1. 'test': 3 documents, 5 hits
wget http://sphinxsearch.googlecode.com/svn/trunk/api/sphinxapi.phpwget http://sphinxsearch.googlecode.com/svn/trunk/api/test.phpphp test.php test

原文出处:Netkiller 系列 手札
本文作者:陈景峯
转载请与作者联系,同时请务必标明文章原始出处和作者信息及本声明。

你可能感兴趣的文章
Terratest:一个用于自动化基础设施测试的开源Go库
查看>>
修改Windows远程终端默认端口,让服务器更安全
查看>>
扩展器必须,SAS 2.0未必(SAS挺进中端存储系统之三)
查看>>
Eclipse遇到Initializing Java Tooling解决办法
查看>>
while((ch = getchar()) != '\n')
查看>>
好程序员web前端分享JS检查浏览器类型和版本
查看>>
Oracle DG 逻辑Standby数据同步性能优化
查看>>
exchange 2010 队列删除
查看>>
「翻译」逐步替换Sass
查看>>
H5实现全屏与F11全屏
查看>>
处理excel表的列
查看>>
C#数据采集类
查看>>
quicksort
查看>>
【BZOJ2019】nim
查看>>
四部曲
查看>>
LINUX内核调试过程
查看>>
【HDOJ】3553 Just a String
查看>>
Java 集合深入理解(7):ArrayList
查看>>
2019年春季学期第四周作业
查看>>
linux环境配置
查看>>