Sphinx Simple installation and use under Windows

Source: Internet
Author: User
Tags server port

1, http://sphinxsearch.com/downloads/release/, I here is "Win64 binaries w/mysql+pgsql+libstemmer+id64 support", File name after download: sphinx-2.0.6-release-win64-id64-full.zip;

2, unzip it to D: \ Sphinx, and in D:\sphinx under the new directory data (used to store the index file) and log (to hold the log file); 3, copy D:\sphinx\sphinx.conf.in to D:\sphinx\bin\ Sphinx.conf.in, andRenamed to sphinx.conf;4, modify D:\sphinx\bin\sphinx.conf as follows: 4.1, search for source Src1 modify {...} Content in # used database type = mysql # server sql_host = localhost # database login Sql_user = ro OT # database login Password Sql_pass = root # operation database name sql_db = test # database server Port Sql_port = 3 306 # Set the encoding if you are using UTF-8 encoding Sql_query_pre = set NAMES utf-8 (If you have # to remove it before 7)4.2, search index test1 modify {...} Contents of the # Index directory path = d:/sphinx/data/# encoded charset_type = utf-8 # Specify UTF-8 encoded table ch arset_table = 0..9, A.. Z->a. Z, _, a.. Z, u+410..u+42f->u+430..u+44f, u+430..u+44f # simple participle, only 0 and 1, need to search Chinese must set 1 Ngram_len = 1 # characters that need word breaker, search Chinese Must be ngram_chars = u+3000..u+2fa1f (If you have # to remove it before 5)5. Import the test data to execute the statement in D:\sphinx\example.sql into the test database, note:the test database needs to be specified as the Utf-8 format when it is created;6. Open the cmd window,Enter directory D:\sphinx\bin;7, indexing, implementation Indexer.exe test1, Test1 is the index test1 in sphinx.conf
Sphinx 2.0.6-id64-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (c) 2008-2012, Sphinx Technologies Inc (Http://sphin using config file './sphinx.conf ' ... indexing index ' test1 ' ... collected 4 docs, 0.0 MB sorted 0.0 mhits, 100.0% done Total 4 docs, 222 bytes Total 0.019 sec, 11252 bytes/sec, 202.74 docs/sec Total 2 Reads, 0.000 sec, 0.2 kb/call avg, 0.0 msec/call avg Total 9 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
Success... 8. Search ' Test ', execute Search.exe Test
Sphinx 2.0.6-id64-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (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 sec displaying matches: 1. Document=1, weight=2421, group_id=1, Date_added=tue Feb 10:25:31 id=1 group_id=1 group_id2=5 date_added=2013-02-26 10:25:31 Title=test One Content=this is my test document number one. Also checking search within phrases. 2. document=2, weight=1442, group_id=3, Date_added=tue Feb 10:25:31 id=2 group_id=3 group_id2=6 date_added=2013-02-26 10:25:31 title=???? Content=this is my test document number??????? 3. document=4, weight=1442, group_id=2, Date_added=tue Feb 10:25:31 id=4 group_id=2 group_id2=8 date_added=2013-02-26 10:25:31 Title=doc number Four Content=this is to test groups words: 1. ' Test ': 3 documents, 4 hits index ' test1stemmed ': Search error:failed to open D:/sphinx/data/test1stemmed.s ph:no such file or directory.
The last sentence error can be ignored; 9, search Chinese, first of all the contents of the database update contains Chinese, execute the SQL statement:
UPDATE documents SET title= ' Chinese ', content= ' This is my test document number one. Also checking search within phrases . Contains Chinese. ' WHERE id=1; UPDATE documents SET title= ' Chinese title ', content= ' This is my test document number one. Also checking search within phrases. Included Chinese content is available. ' WHERE id=2; UPDATE documents SET title= ' Chinese title test ', content= ' This is my test document number one. Also checking search within phrases . contains Chinese content. ' WHERE id=3;
re-index (perform step 7th); then execute search.exe Chinese
Sphinx 2.0.6-id64-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com) using config file './sphinx.conf ' ... indexing index ' test1 ' ... collected 4 docs, 0.0 MB sorted 0.0 mhits, 100.0% done Total 4 docs, 349 bytes Total 0.025 sec, 13808 bytes/sec, 158.26 docs/sec Total 2 Reads, 0.000 sec, 0.3 kb/call AVG, 0.0 msec/call avg Total 9 writes, 0.000 sec, 0.2 kb/call avg, 0.0 msec/call avg D:\sphinx\bin>search.exe Chinese Sphinx 2.0.6-id64-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com) using config file './sphinx.conf ' ... index ' test1 ': Query ' Chinese ': returned 0 matches of 0 Total in 0.000 sec words: index ' test1stemmed ': Search error:failed to open D:/sphinx/data/test1stemmed.s ph:no such file or directory.
there is no matching content because the GBK encoding format is not found because of the Chinese language in the Windows command line. We can use the PHP program to try;10, enter the D:\sphinx\api\ directory, you can find Sphinx support PHP, Java, Ruby Call, and provide the corresponding test example, here we use PHP to operate, first copy the API to D:\www\ and renamed to Sphinxapi, Because I am on this machine Apache web directory for D:\www, under D:\www\sphinxapi\ new search.php, content is:
<?php require ' sphinxapi.php '; $s = new sphinxclient (); $s->setserver (' localhost ', 9312); $result = $s->query (' China '); Print_r ($result); echo ' <br/><br/> '; $result = $s->query (' Chinese '); Print_r ($result); ?>
Then go back to the cmd command line, turn on the Sphinx service, execute Searchd.exe(this has to be done)
Sphinx 2.0.6-id64-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com) using config file './sphinx.conf ' ... Warning:compat_sphinxql_magics=1 is deprecated, please update your application and config Warning:preopen_indexes=1 have no effect with seamless_rotate=0 listening on all interfaces, port=9312 listening on all interfaces, port=9306 precaching index ' test1 ' precaching index ' test1stemmed ' warning:index ' test1stemmed ': preload:failed to open D:/sphinx/data/test1stemm ed.sph:No such file or directory; Not serving precaching index ' RT ' Warning:index ' RT ': preload:failed to open @[email protected]/data/rt.lock:no such fil e or directory; Not serving precached 3 Indexes in 0.018 sec
Success... And then execute it in the browser.http://localhost/sphinxapi/search.php, the printed array results can be clearly seen in the results of the search ... 11, the simple installation and use of Sphinx under Windows is complete ...
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.