Sphinx -php Tutorial

Source: Internet
Author: User
The configuration of sphinx matching seems to be okay. the matching result can be obtained in the command line, but no result is returned when it is introduced into PHP. CORESEEK is used.
I just learned sphinx today. I don't know where the problem is, and I haven't encountered any similar problems during online queries:
This is the configuration file:
# MySQL data source configuration. for details, see: http://www.coreseek.cn/products-install/mysql/# Please first convert var/test/documents. SQL import database, configure the following MySQL User password database # source definition source cetsix {type = mysql SQL _host = localhost SQL _user = root SQL _pass = cai123 SQL _db = words SQL _port = 3306 SQL _query_pre = SET NAMES UTF8sql_query = SELECT id, meaning, lx FROM cetsix} # index defines index cetsix {source = cetsix # corresponding source name path = E: \ CodeEdit \ php \ ciba \ niujin-alpha \ sphinx \ var \ data \ cetsix docinfo = extern mlock = 0 morphology = none min_word_len = 1 html_strip = 0 charset_dictpath = E: \ CodeEdit \ php \ ciba \ niujin-alpha \ sphinx \ etc charset_type = UTF-8} indexer {mem_limit = 128 M} # searchd service definition searchd {listen = 3312 read_timeout = 5 max_children = 30 max_matches = 100 seamless_rotate = 1 preopen_indexes = 0 unlink_old = 1 # maximum number of filters allowed max_filters = 256 # maximum number of values allowed by each filter max_filter_values = 4096 # log file storage path pid_file = e: \ CodeEdit \ php \ ciba \ niujin-alpha \ sphinx \ var \ log \ searchd_mysql.pid log = E: \ CodeEdit \ php \ ciba \ niujin-alpha \ sphinx \ var \ log \ searchd_mysql.log query_log = E: \ CodeEdit \ php \ ciba \ niujin-alpha \ sphinx \ var \ log \ query_mysql.log}


This is the PHP test code:
 setServer("127.0.0.1", 3312);$sphinx->setMatchMode('SPH_MATCH_ANY');$res = $sphinx->query('man', "cetsix");var_dump($res);?>

The database code is as follows:
mysql> SHOW CREATE TABLE cetsix    -> ;+--------+---------------------------------------------------| Table  | Create Table+--------+---------------------------------------------------| cetsix | CREATE TABLE `cetsix` (  `id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,  `word` varchar(255) NOT NULL,  `meaning` varchar(255) NOT NULL,  `lx` text NOT NULL,  PRIMARY KEY (`id`)) ENGINE=MyISAM AUTO_INCREMENT=13325 DEFAULT CHARSET=utf8 |+--------+---------------------------------------------------

The command line can return the result:

C: \ windows \ system32> E: \ CodeEdit \ php \ ciba \ niujin-alpha \ sphinx \ bin \ search.exe -- c
Onfig E: \ CodeEdit \ php \ CBA \ niujin-alpha \ sph?\ sph=. conf man
Coreseek Fulltext 3.2 [sph00000.9.9-release (r2117)]
Copyright (c) 2007-2011,
Beijing Choice Software Technologies Inc (http://www.coreseek.com)

Using config file 'E: \ CodeEdit \ php \ CBA \ niujin-alpha \ sph?\ sph=. Conf '...
Index 'cetsix': query 'Man ': returned 199 matches of 199 total in 0.001 sec

Displaying matches:
1. document = 4, weight = 1
2. document = 10, weight = 1
3. document = 24, weight = 1
4. document = 45, weight = 1
5. document = 186, weight = 1
6. document = 193, weight = 1
7. document = 239, weight = 1
8. document = 240, weight = 1
9. document = 394, weight = 1
10. document = 454, weight = 1
11. document = 466, weight = 1
12. document = 483, weight = 1
13. document = 514, weight = 1
14. document = 543, weight = 1
15. document = 653, weight = 1
16. document = 750, weight = 1
17. document = 930, weight = 1

The service is also started normally .. I really don't know what went wrong.


Reply to discussion (solution)

After reading the manual, I solved the problem and sent the score.

I saw a score in the morning.

Points received

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.