- D:\sphinx\searchd --install --config d:\sphinx\sphinx.conf --servicename SphinxSearch
常见问题1
- $ tar xzvf sphinx-0.9.8.tar.gz
- $ cd sphinx
- $ ./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql
- $ make
- $ make install
- /usr/local/sphinx-0.9.9/src/sphinx.cpp:20060: undefined reference to `libiconv_open'
- /usr/local/sphinx-0.9.9/src/sphinx.cpp:20078: undefined reference to `libiconv'
- /usr/local/sphinx-0.9.9/src/sphinx.cpp:20084: undefined reference to `libiconv_close'
- collect2: ld returned 1 exit status
- make[2]: *** [indexer] Error 1
- make[2]: Leaving directory `/home/jling/sphinx-0.9.9/src'
- make[1]: *** [all] Error 2
- make[1]: Leaving directory `/home/jling/sphinx-0.9.9/src'
- make: *** [all-recursive] Error 1
解决办法:
- error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory
- source main
- {
- type = mysql #数据库类型
- sql_host = 10.228.134.211 #数据库ip
- sql_user = admin #数据库用户名
- sql_pass = admin #数据库密码
- sql_db = phpcms_v9 #数据库名
- sql_port = 3306 # 数据库端口
- sql_query_pre = SET NAMES utf8
- sql_query_pre = REPLACE INTO v9_sphinx_counter SELECT 1, MAX(searchid) FROM v9_search
- sql_query = SELECT searchid, adddate, siteid, typeid, id, data FROM v9_search \
- WHERE searchid>=$start AND searchid<=$end
- sql_query_range = SELECT 1,max_doc_id FROM v9_sphinx_counter WHERE counter_id=1
- sql_range_step = 5000
- #字符串属性设置、需要过滤、排序的时候用到
- sql_attr_uint = typeid
- sql_attr_uint = siteid
- sql_attr_uint = id
- sql_attr_timestamp = adddate
- sql_query_info = SELECT * FROM v9_search WHERE searchid=$id
- }
- source delta
- {
- type = mysql #数据库类型
- sql_host = 10.228.134.211 #数据库ip
- sql_user = admin #数据库用户名
- sql_pass = admin #数据库密码
- sql_db = phpcms_v9 #数据库名
- sql_port = 3306 # 数据库端口
- sql_query_pre = SET NAMES utf8
- sql_query = SELECT searchid, adddate, siteid, typeid, id, data FROM v9_search \
- WHERE searchid >( SELECT max_doc_id FROM v9_sphinx_counter WHERE counter_id=1 )
- sql_query_post = REPLACE INTO v9_sphinx_counter SELECT 1, MAX(searchid) FROM v9_search
- #字符串属性设置、需要过滤、排序的时候用到
- sql_attr_uint = typeid
- sql_attr_uint = siteid
- sql_attr_uint = id
- sql_attr_timestamp = adddate
- sql_query_info = SELECT * FROM v9_search WHERE searchid=$id
- }
- #主索引
- index main
- {
- source = main
- # 放索引的目录
- path = D:\sphinx\data\main
- # 编码
- charset_type = utf-8
- # 指定utf-8的编码表
- charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
- # 简单分词,只支持0和1,如果要搜索中文,请指定为1
- ngram_len = 1
- # 需要分词的字符,如果要搜索中文,去掉前面的注释
- ngram_chars = U+3000..U+2FA1F
- }
- #增量索引
- index delta
- {
- source = delta
- path = D:\sphinx\data\delta
- # 编码
- charset_type = utf-8
- # 指定utf-8的编码表
- charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
- # 简单分词,只支持0和1,如果要搜索中文,请指定为1
- ngram_len = 1
- # 需要分词的字符,如果要搜索中文,去掉前面的注释
- ngram_chars = U+3000..U+2FA1F
- }
- indexer
- {
- mem_limit = 128M
- }
- searchd
- {
- port = 9312
- log = D:\sphinx\data\phpcms\searchd.log
- query_log = D:\sphinx\data\phpcms\query.log
- read_timeout = 5
- max_children = 30
- pid_file = D:\sphinx\data\phpcms\searchd.pid
- max_matches = 2000
- seamless_rotate = 0
- preopen_indexes = 0
- unlink_old = 1
- }
delta.bat
- @ECHO off
- D:\sphinx\bin\indexer.exe --config D:\sphinx\sphinx.conf --merge main delta --rotate
- echo indexing, window will close when complete
- @ECHO off
- D:\sphinx\bin\indexer.exe --config D:\sphinx\sphinx.conf delta --rotate
- echo indexing, window will close when complete
- #凌晨4点合并索引,其余时间每分钟更新索引
- * 0-3 * * * /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf delta --rotate
- * 6-23 * * * /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf delta --rotate
- 0 4 * * * /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --merge main delta --rotate