博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
sphinx安装测试
阅读量:4709 次
发布时间:2019-06-10

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

sphinx 是模拟mysql数据库协议,所以在安装sphinx之前要先装好mysql相关服务。

1.去sphinx官网下载需要的包  地址:  http://sphinxsearch.com/downloads/

   

 然后编译指定安装路径

 

./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql    make      make install

  

      其中--prefix是指向sphinx的安装路径,--with-mysql是指向mysql的安装路径。如果上面都没有报错,那sphinx就成功安装了。

      sphinx的配置文件为sphinx.conf,下面进行配置:

    进入/usr/local/sphinx/etc文件夹下,看到该文件夹下有下面这些文件:

-rw-r--r-- 1 root root   905 11-04 13:32 example.sql-rw-r--r-- 1 root root 19003 11-04 13:32 sphinx.conf.dist-rw-r--r-- 1 root root   948 11-04 13:32 sphinx-min.conf.dist

  

 把sphinx.conf.dist复制出来成sphinx.conf,并进入修改它的一些数据库的配置,主要是修改数据库地址,数据库用户、密码,还有数据库名这些,这里我们用安装mysql自带的test库进行测试。

      运行该目录下的example.sql脚本,把数据导到数据库中:

mysql -u mysql < /usr/local/sphinx/etc/example.sql

  然后进入mysql中查看添加的数据:

Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->mysql  #进入mysqlshow databases;# 查看到有下面这些库mysql> show databases;+--------------------+| Database           |+--------------------+| information_schema | | mysql              | | test               | +--------------------+rows in set (0.00 sec)#进入test库,查看到有下面这些表,其中documents表是自动导进来的:mysql> use testDatabase changedmysql> show tables;+----------------+| Tables_in_test |+----------------+| documents      | | eht_articles   | | tags           | +----------------+rows in set (0.01 sec)查询documents表就能看到下面记录:mysql> SELECT * FROM documents;+----+----------+-----------+---------------------+-----------------+---------------------------------------------------------------------------+| id | group_id | group_id2 | date_added          | title           | content                                                                   |+----+----------+-----------+---------------------+-----------------+---------------------------------------------------------------------------+|  1 |        1 |         5 | 2010-11-04 19:22:13 | test one        | this is my test document number one. also checking search within phrases. | |  2 |        1 |         6 | 2010-11-04 19:22:13 | test two        | this is my test document number two                                       | |  3 |        2 |         7 | 2010-11-04 19:22:13 | another doc     | this is another group                                                     | |  4 |        2 |         8 | 2010-11-04 19:22:13 | doc number four | this is to test groups                                                    | +----+----------+-----------+---------------------+-----------------+---------------------------------------------------------------------------+rows in set (0.00 sec)

   sphinx的配置文件也创建完了,数据也导进去了,接下来就用下面命令来创建索引:

/usr/local/sphinx/bin/indexer --all

  然后用下面命令进行搜索测试:

/usr/local/sphinx/bin/search test  #test是搜索的关键字

  搜索成功会出现下面的内容:

代码 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->Sphinx 0.9.9-release (r2117)Copyright (c) 2001-2009, Andrew Aksyonoffusing config file '/usr/local/sphinx/etc/sphinx.conf'...index 'test1': query 'test ': returned 3 matches of 3 total in 0.001 secdisplaying matches:1. document=1, weight=2, group_id=1, date_added=Thu Nov  4 19:22:13 2010        id=1        group_id=1        group_id2=5        date_added=2010-11-04 19:22:13        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=Thu Nov  4 19:22:13 2010        id=2        group_id=1        group_id2=6        date_added=2010-11-04 19:22:13        title=test two        content=this is my test document number two3. document=4, weight=1, group_id=2, date_added=Thu Nov  4 19:22:13 2010        id=4        group_id=2        group_id2=8        date_added=2010-11-04 19:22:13        title=doc number four        content=this is to test groupswords:1. 'test': 3 documents, 5 hitsindex 'test1stemmed': query 'test ': returned 3 matches of 3 total in 0.000 secdisplaying matches:1. document=1, weight=2, group_id=1, date_added=Thu Nov  4 19:22:13 2010        id=1        group_id=1        group_id2=5        date_added=2010-11-04 19:22:13        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=Thu Nov  4 19:22:13 2010        id=2        group_id=1        group_id2=6        date_added=2010-11-04 19:22:13        title=test two        content=this is my test document number two3. document=4, weight=1, group_id=2, date_added=Thu Nov  4 19:22:13 2010        id=4        group_id=2        group_id2=8        date_added=2010-11-04 19:22:13        title=doc number four        content=this is to test groupswords:1. 'test': 3 documents, 5 hits

  到此安装成功并且测试成功

 

转载于:https://www.cnblogs.com/tong775131501/p/5969289.html

你可能感兴趣的文章
dcm4chee 修改默认(0002,0013) ImplementationVersionName
查看>>
maven3在eclipse3.4.2中创建java web项目
查看>>
POJ 2378 Tree Cutting(树形DP,水)
查看>>
UVA 116 Unidirectional TSP (白书dp)
查看>>
cnblog!i'm coming!
查看>>
fatal: remote origin already exists.
查看>>
LeetCode 242. Valid Anagram
查看>>
JSP表单提交乱码
查看>>
如何适应现代雇佣关系
查看>>
团队项目(第五周)
查看>>
SQL 优化经验总结34条
查看>>
开源 视频会议 收藏
查看>>
核心J2EE模式 - 截取过滤器
查看>>
.net开源CMS
查看>>
JdbcTemplate
查看>>
第一次使用maven记录
查看>>
SharePoint服务器端对象模型 之 使用CAML进展数据查询
查看>>
Building Tablet PC Applications ROB JARRETT
查看>>
Adobe® Reader®.插件开发
查看>>
【POJ 3461】Oulipo
查看>>