1, Download Sphinx search engine from Sphinx
1 2 3
| wget http://www.sphinxsearch.com/downloads/sphinx-0.9.8.tar.gz
tar xzvf sphinx-0.9.8.tar.gz
|
2, Install MySQL mysql-devel
3, Configure Sphinx
1 2 3 4
| cd sphinx-0.9.8 ./configure --prefix /home/sphinx/sphinxsearch --with-mysql make make install
|
4, Create a configuration file
1 2
| cd /home/sphinx/sphinxsearch/etc cp sphinx.conf.dist sphinx.conf
|
5, Edit sphix.conf
vi sphinx.conf
Configuration file sphinx.conf for wordpress
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| source mywhiteboard { type = mysql sql_host = localhost sql_user = mywhiteboard sql_pass = a1b2c3z4y5x6 sql_db = ivdb sql_port = 3306 sql_query = SELECT id, post_title, post_content FROM wp_posts sql_query_info = SELECT * FROM wp_posts WHERE id =$id }
index mywhiteboard { source = mywhiteboard path = /home/sphinx/sphinxsearch/var/data/mywhiteboard docinfo = extern mlock = 0 morphology = stem_en enable_star=1
stopwords = /home/sphinx/sphinxsearch/var/data/stopwords.txt min_word_len = 3 charset_type = sbcs min_prefix_len = 0 min_infix_len = 3 html_strip = 1 html_remove_elements = style, script }
indexer { mem_limit = 256M } searchd { port = 3312 log = /home/sphinx/sphinxsearch/var/log/searchd.log query_log = /home/sphinx/sphinxsearch/var/log/query.log read_timeout = 5 max_children = 30 pid_file = /home/sphinx/sphinxsearch/var/log/searchd.pid max_matches = 1000 seamless_rotate = 1 preopen_indexes = 0 unlink_old = 1 }
|
6, make a directory for indexes
mkdir /home/sphinx/sphinxsearch/var/data/mywhiteboard
7, Start indexer:
home/sphinx/sphinxsearch/bin/indexer --config /home/sphinx/sphinxsearch/etc/sphinx.conf --all
Sphinx 0.9.8-release (r1371)
Copyright (c) 2001-2008, Andrew Aksyonoff
using config file '/home/sphinx/sphinxsearch/etc/sphinx.conf'...
indexing index 'mywhiteboard'...
collected 1104407 docs, 1938.9 MB
sorted 6551.8 Mhits, 98.5% donedone
total 1104407 docs, 1938867135 bytes
total 5126.826 sec, 378180.78 bytes/sec, 215.42 docs/sec
8, To test if it is working:
1
| /home/sphinx/sphinxsearch/bin/search --config /home/sphinx/sphinxsearch/etc/sphinx.conf insulin
|
....
20\. document=9345, weight=3
id=9345
....
words:
1\. 'insulin': 30601 documents, 109926 hits
1 2 3 4 5 6 7 8 9 10
| ls -la /home/sphinx/sphinxsearch/var/data/mywhiteboard drwxr-xr-x 3 root root 4096 Oct 21 16:20 . drwxr-xr-x 4 root root 4096 Sep 11 20:08 .. -rw-r--r-- 1 root root 0 Oct 21 15:32 mywhiteboard.spa -rw-r--r-- 1 root root 14925566596 Oct 21 16:20 mywhiteboard.spd -rw-r--r-- 1 root root 237 Oct 21 16:20 mywhiteboard.sph -rw-r--r-- 1 root root 57254921 Oct 21 16:20 mywhiteboard.spi -rw-r--r-- 1 root root 0 Oct 21 15:32 mywhiteboard.spm -rw-r--r-- 1 root root 22721504506 Oct 21 16:20 mywhiteboard.spp
|
wordpress-sphinx-search 插件的安装教程
http://www.ivinco.com/software/wordpress-sphinx-search-tutorial/