wget http://sphinxsearch.com/files/sphinx-2.2.11-release.tar.gz
tar -xf sphinx-2.2.11-release.tar.gz && cd sphinx-2.2.11-release
./configure --prefix=/usr/local/spinx --with-mysql
make && make install
ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib64/
libsphinxclient 安装(PHP模块需要)
cd api/libsphinxclient
./configure –prefix=/usr/local/sphinx
make && make install
2.安装php扩展
1
2
3
4
wget http://pecl.php.net/get/sphinx-1.3.0.tgz
tar zxf sphinx-1.3.3.tgz && cd sphinx-1.3.3
./configure --with-php-config=/usr/local/php/bin/php-config --with-sphinx=/usr/local/sphinx/
make && make install
cd /root/sphinx-2.2.11-release/api
python test.py test
DEPRECATED: Do not call this method or, even better, use SphinxQL instead of an API
Query 'test ' retrieved 3 of 3 matches in 0.000 sec
Query stats:
'test' found 5 times in 3 documents
Matches:
1. doc_id=1, weight=2, group_id=1, date_added=2016-11-30 01:21:20
2. doc_id=2, weight=2, group_id=1, date_added=2016-11-30 01:21:20
3. doc_id=4, weight=1, group_id=2, date_added=2016-11-30 01:21:20
1
2
3
4
5
6
7
8
9
mysql> select * from documents;
+----+----------+-----------+---------------------+-----------------+---------------------------------------------------------------------------+
| id | group_id | group_id2 | date_added | title | content |
+----+----------+-----------+---------------------+-----------------+---------------------------------------------------------------------------+
| 1 | 1 | 5 | 2016-11-30 01:21:20 | test one | this is my test document number one. also checking search within phrases. |
| 2 | 1 | 6 | 2016-11-30 01:21:20 | test two | this is my test document number two |
| 3 | 2 | 7 | 2016-11-30 01:21:20 | another doc | this is another group |
| 4 | 2 | 8 | 2016-11-30 01:21:20 | doc number four | this is to test groups |
+----+----------+-----------+---------------------+-----------------+---------------------------------------------------------------------------+