我在 localhost (wamp) 上安装了 sphinx search。例如,我想在一个简单的 html 表格中显示结果。我试图用 php 连接到 sphinx 搜索,我认为它做到了,但是当我打印结果时它是 0.... 但这不是真的。我不太明白在查询部分我需要输入我想要搜索的词吗?我尝试在命令窗口中搜索,效果很好,只是我不知道如何在网页上显示它。我想使用mysql。所以我的PHP看起来像这样:
require ( "sphinx/api/sphinxapi.php" );
$s = new SphinxClient;
$s->setServer("localhost", 9306);
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3);
$result = $s->query("test");
var_dump($result);
这是我的迷你 conf 文件:
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, group_id, UNIX_TIMESTAMP(date_added) AS date_added, title, content \
FROM documents
sql_attr_uint = group_id
sql_attr_timestamp = date_added
sql_query_info = SELECT * FROM documents WHERE id=$id
}
index test1
{
source = src1
path = C:/wamp/www/sphinx/data/test1
docinfo = extern
charset_type = sbcs
}
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
}