1、下载地址 http://sphinxsearch.com/downloads/release/,我这里下的是“Win64 binaries w/MySQL+PgSQL+libstemmer+id64 support”,下载后文件名:sphinx-2.0.6-release-win64-id64-full.zip;
Sphinx 2.0.6-id64-release (r3473)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinusing config file './sphinx.conf'...indexing index 'test1'...collected 4 docs, 0.0 MBsorted 0.0 Mhits, 100.0% donetotal 4 docs, 222 bytestotal 0.019 sec, 11252 bytes/sec, 202.74 docs/sectotal 2 reads, 0.000 sec, 0.2 kb/call avg, 0.0 msec/call avgtotal 9 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
Sphinx 2.0.6-id64-release (r3473)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)using config file './sphinx.conf'...index 'test1': query 'test ': returned 3 matches of 3 total in 0.000 secdisplaying matches:1. document=1, weight=2421, group_id=1, date_added=Tue Feb 26 10:25:31 2013id=1group_id=1group_id2=5date_added=2013-02-26 10:25:31title=test onecontent=this is my test document number one. also checking search withinphrases.2. document=2, weight=1442, group_id=3, date_added=Tue Feb 26 10:25:31 2013id=2group_id=3group_id2=6date_added=2013-02-26 10:25:31title= ????content=this is my test document number two ???????3. document=4, weight=1442, group_id=2, date_added=Tue Feb 26 10:25:31 2013id=4group_id=2group_id2=8date_added=2013-02-26 10:25:31title=doc number fourcontent=this is to test groupswords:1. 'test': 3 documents, 4 hitsindex 'test1stemmed': search error: failed to open D:/sphinx/data/test1stemmed.sph: No such file or directory.
UPDATE documents SET title='中文', content='this is my test document number one. also checking search within phrases.含有中文。' WHERE id=1;UPDATE documents SET title='中文标题', content='this is my test document number one. also checking search within phrases.含有中文内容。' WHERE id=2;UPDATE documents SET title='中文标题测试', content='this is my test document number one. also checking search within phrases.含有中文内容。' WHERE id=3;
重新建立索引(执行第7步);然后执行 search.exe 中文
Sphinx 2.0.6-id64-release (r3473)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)using config file './sphinx.conf'...indexing index 'test1'...collected 4 docs, 0.0 MBsorted 0.0 Mhits, 100.0% donetotal 4 docs, 349 bytestotal 0.025 sec, 13808 bytes/sec, 158.26 docs/sectotal 2 reads, 0.000 sec, 0.3 kb/call avg, 0.0 msec/call avgtotal 9 writes, 0.000 sec, 0.2 kb/call avg, 0.0 msec/call avgD:\sphinx\bin>search.exe 中文Sphinx 2.0.6-id64-release (r3473)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)using config file './sphinx.conf'...index 'test1': query '中文 ': returned 0 matches of 0 total in 0.000 secwords:index 'test1stemmed': search error: failed to open D:/sphinx/data/test1stemmed.sph: No such file or directory.
<?phprequire 'sphinxapi.php';$s = new SphinxClient();$s->SetServer('localhost', 9312);$result = $s->Query('中国');print_r($result);echo '<br /><br />';$result = $s->Query('中文');print_r($result);?>
Sphinx 2.0.6-id64-release (r3473)Copyright (c) 2001-2012, Andrew AksyonoffCopyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)using config file './sphinx.conf'...WARNING: compat_sphinxql_magics=1 is deprecated; please update your applicationand configWARNING: preopen_indexes=1 has no effect with seamless_rotate=0listening on all interfaces, port=9312listening on all interfaces, port=9306precaching index 'test1'precaching index 'test1stemmed'WARNING: index 'test1stemmed': preload: failed to open D:/sphinx/data/test1stemmed.sph: No such file or directory; NOT SERVINGprecaching index 'rt'WARNING: index 'rt': preload: failed to open @CONFDIR@/data/rt.lock: No such file or directory; NOT SERVINGprecached 3 indexes in 0.018 sec