我有一个关于sphinx配置和php api使用的问题(在Windows7上)。
我已经配置了索引器: indexer --config sphinx.conf test1并启动了服务: searchd -- sphinx.conf --config cmd当我使用cmd控制台进行搜索时,我找到了结果,但是...不能使用php api。
这里出现错误:查询失败:无法读取搜索响应(status=2613,ver=11830,len=774976045,read=70)。
下面是我的conf文件:
#
# Minimal Sphinx configuration sample (clean, simple, functional)
#
source src1
{
type = mysql
sql_host = localhost
sql_user = root
sql_pass =
sql_db = test
sql_port = 3306 # optional, default is 3306
sql_query = \
SELECT id, UNIX_TIMESTAMP(addTime) AS addTime, title, brand, material, size, description, c.name as categoryName \
FROM test \
JOIN category c ON c.id = advert.categoryId
sql_attr_uint = id
sql_attr_timestamp = addTime
sql_query_info = SELECT * FROM test WHERE id=$id
}
index catalog
{
source = src1
path = C:\wamp\www\sphinx\catalog
docinfo = extern
charset_type = utf-8
min_word_len = 3
min_prefix_len = 0
min_infix_len = 3
}
indexer
{
mem_limit = 32M
}
searchd
{
listen = 9312
listen = 9306:mysql41
log = C:\wamp\www\sphinx\log\searchd.log
query_log = C:\wamp\www\sphinx\log\query.log
read_timeout = 5
max_children = 30
pid_file = C:\wamp\www\sphinx\log\searchd.pid
max_matches = 1000
seamless_rotate = 1
preopen_indexes = 1
unlink_old = 1
workers = threads # for RT to work
binlog_path = C:\wamp\www\sphinx\data
}php文件:
<?php
include('sphinxapi.php');
//Sphinx
$s = new SphinxClient;
$s->setServer("localhost", 3306);
$s->setMatchMode(SPH_MATCH_EXTENDED2);
$result = $s->query("@title jean");
if ($result['total'] > 0) {
foreach ($result['matches'] as $id => $otherStuff) {
echo $id;
}
} else {
echo "Query failed: " . $s->GetLastError() . ".\n";
}?>
发布于 2013-11-29 22:22:25
您在php脚本3306 -它的mysql服务器的端口行:
$s->setServer("localhost", 3306);尝试指向端口9312
还可以尝试执行以下步骤:
带有配置文件完整路径的searchd --delete
搜索--安装--配置fullPathToSphinx.conf
services.msc运行,并在服务列表中找到searchd并启动它。发布于 2013-12-23 12:54:24
在Windows上不要使用"localhost“。
$s->setServer("127.0.0.1",9312);
https://stackoverflow.com/questions/20287685
复制相似问题