在PHP中使用Sphinx。 “搜索”错误:“搜索错误:。”
我用PHP测试狮身人面像(教程:http://www.siteduzero.com/informatique/tutoriels/creer-un-moteur-de-recherche-avec-sphinx-et-php)在PHP中使用Sphinx。 “搜索”错误:“搜索错误:。”
如果我运行 “搜索” 是这样的:
search -i news navigateur
我有以下错误:
index 'news': search error: .
索引器作品罚款:
$ sudo indexer news
Sphinx 2.0.6-release (r3473) Copyright (c) 2001-2012, Andrew Aksyonoff Copyright (c) 2008-2012, Sphinx Technologies Inc (http://sphinxsearch.com)using config file '/usr/share/php/sphinx/etc/sphinx.conf'... indexing index 'news'...
collected 57 docs, 0.7 MB sorted 0.1 Mhits, 100.0%
done total 57 docs, 689264 bytes total 0.050 sec, 13684561 bytes/sec, 1131.67 docs/sec
total 3 reads, 0.000 sec, 115.5 kb/call avg, 0.1 msec/call avg
total 9 writes, 0.000 sec, 83.5 kb/call avg, 0.0 msec/call avg
而且,用th e API,PHP代码不会返回任何内容。有人已经有这个错误?
这里的配置文件:
index news {
source = news path = /usr/share/php/sphinx/var/data/news
}
indexer {
mem_limit = 32M
}
searchd {
port = 3312 log = /usr/share/php/sphinx/var/log/searchd/searchd.log query_log = /usr/share/php/sphinx/var/log/searchd/query.log pid_file = /usr/share/php/sphinx/var/log/searchd/searchd.pid
}
source news {
type = mysql sql_host = localhost sql_user = root sql_pass = sql_db = siteduzero_sphinx sql_query_pre = SET NAMES utf8 sql_query = SELECT id\ , categorie\ , titre\ , contenu FROM news sql_attr_uint = categorie sql_query_info = SELECT titre FROM news WHERE id=$id }
感谢。
法布里斯
它在search
实用的错误。
好消息是search
实用程序,只是一个测试工具,所以它并不重要。它没有实际用于测试以外的其他任何事情。
至于你在API方面的问题,你有没有运行searchd
守护进程?
而不是只是说,它返回“无”,你应该使用GetLastError和getLastWarning调查为什么...
恰好碰到了同样的问题。最后一个配置参数中邪恶的根源。此命令将正常工作:
search -i news --noinfo navigateur
或者你也可以从配置中删除该字符串:
sql_query_info = SELECT titre FROM news WHERE id=$id
如果你不需要它。