SphinxAPI SetFilter false
我为我的搜索引擎安装了 sphinx,它工作得很好,但现在我尝试使用 setFilter() 向搜索添加一些额外的功能,这应该允许我执行 WHERE/AND 子句,但每当我尝试搜索时,它应该返回结果但没有返回结果。
这是我的 MySQL 代码:http://pastebin.com/gFrvKumW
这是我的 sphinx.conf:http://pastebin.com/XdppZ0MG
而我的 PHP 代码:
<?php
require("sphinxapi.php");
$cl = new SphinxClient();
$host = "localhost";
$port = 9312;
$index = "library";
$q = "livres";
$limit = 20;
$ranker = SPH_RANK_PROXIMITY_BM25;
$mode = SPH_MATCH_ALL;
$cl->SetServer($host, $port);
$cl->SetConnectTimeout(0);
$cl->SetMatchMode($mode);
$cl->SetRankingMode($ranker);
//$cl->SetFilter('author_id', array(1));
$res = $cl->Query($q, $index);
die(var_dump($res));
?>
如果添加注释行就不再工作了。 我不明白为什么
I have sphinx installed for my search engine, and it works great, but now I'm trying to add a few extra features to the search using setFilter() which should allow me to do WHERE/AND clauses, but whenever I try a search, it returns no results when there should.
This is my MySQL Code : http://pastebin.com/gFrvKumW
This is my sphinx.conf : http://pastebin.com/XdppZ0MG
And my PHP code :
<?php
require("sphinxapi.php");
$cl = new SphinxClient();
$host = "localhost";
$port = 9312;
$index = "library";
$q = "livres";
$limit = 20;
$ranker = SPH_RANK_PROXIMITY_BM25;
$mode = SPH_MATCH_ALL;
$cl->SetServer($host, $port);
$cl->SetConnectTimeout(0);
$cl->SetMatchMode($mode);
$cl->SetRankingMode($ranker);
//$cl->SetFilter('author_id', array(1));
$res = $cl->Query($q, $index);
die(var_dump($res));
?>
if you add the commented line is not working anymore.
I do not understand why
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您希望能够使用字段作为过滤器,则需要将其添加到 sphinx 配置文件 所以如果你想按作者id过滤,你需要添加(假设作者的id是整数):
我希望这有帮助,祝你好运
if you want to be able to use a field as a filter, you'll need to add it in the
sql_attr
on your sphinx config file so if you want to filter by autor id, you'll need to add (assuming that the author's id is an integer):i hope this helps, Good Luck