Sphinx setFilter() 杀死所有结果

发布于 2024-09-17 22:19:09 字数 2062 浏览 7 评论 0原文

我为我的搜索引擎安装了 sphinx,它工作得很好,但现在我尝试使用 setFilter() 向搜索添加一些额外的功能,这应该允许我执行 WHERE/AND 子句,但每当我尝试搜索时,它应该返回结果但没有返回结果。

这是我的工作代码:

 require_once ( "sphinxapi.php" );
 $cl = new SphinxClient ();
 $cl->SetConnectTimeout ( 5 );
 $cl->SetMatchMode ( SPH_MATCH_BOOLEAN );
 $cl->SetSortMode ( SPH_SORT_EXPR  , "@weight" );
 $cl->SetFieldWeights ( array ( "item_title"=>100, "item_tags"=>99 ) );
 $cl->SetLimits(0, 1000, 1000, 1000);
 $cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
 $cl->AddQuery( $term, "indexTubelogr" );

现在我想开始使用 QUERY - AND item_site_id = 1 进行搜索。我添加:

$cl->SetFilter('item_site_id', 1);

然后我收到以下错误:

Warning: assert() [function.assert]: Assertion failed in /home/domain.com/sphinxapi.php on line 810

我也尝试过:

$cl->SetFilter('item_site_id', array(1));

这没有给出错误,但同样没有结果。

我的 sphinx.conf 看起来像:

source srcDomain
{
        type                                    = mysql
        sql_sock                                = /tmp/mysql.sock
        sql_attr_timestamp                      = item_date
        sql_ranged_throttle                     = 0
        sql_query_info                          = SELECT * FROM items WHERE item_id=$id
        sql_query                               = \
                SELECT item_id, item_date, item_runtime, item_title, item_tags, item_site_id FROM items
}
index indexDomain
{
        source                  = srcDomain
        path                    = /opt/sphinx/var/data/domain
        docinfo                 = extern
        mlock                   = 0
        morphology              = stem_en
        min_word_len            = 2
        charset_type            = sbcs
        ignore_chars            = U+00AD
        phrase_boundary         = ., ?, !, U+2026 # horizontal ellipsis
        html_strip              = 0
        preopen                 = 1
}

谁能告诉我我做错了什么?

我从代码中删除了敏感数据。

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 working code:

 require_once ( "sphinxapi.php" );
 $cl = new SphinxClient ();
 $cl->SetConnectTimeout ( 5 );
 $cl->SetMatchMode ( SPH_MATCH_BOOLEAN );
 $cl->SetSortMode ( SPH_SORT_EXPR  , "@weight" );
 $cl->SetFieldWeights ( array ( "item_title"=>100, "item_tags"=>99 ) );
 $cl->SetLimits(0, 1000, 1000, 1000);
 $cl->SetRankingMode ( SPH_RANK_PROXIMITY_BM25 );
 $cl->AddQuery( $term, "indexTubelogr" );

Now I want to start searching with QUERY - AND item_site_id = 1. I add:

$cl->SetFilter('item_site_id', 1);

Then i get the following error:

Warning: assert() [function.assert]: Assertion failed in /home/domain.com/sphinxapi.php on line 810

I also tried:

$cl->SetFilter('item_site_id', array(1));

This didn't give an error, but again, no results.

My sphinx.conf looks like:

source srcDomain
{
        type                                    = mysql
        sql_sock                                = /tmp/mysql.sock
        sql_attr_timestamp                      = item_date
        sql_ranged_throttle                     = 0
        sql_query_info                          = SELECT * FROM items WHERE item_id=$id
        sql_query                               = \
                SELECT item_id, item_date, item_runtime, item_title, item_tags, item_site_id FROM items
}
index indexDomain
{
        source                  = srcDomain
        path                    = /opt/sphinx/var/data/domain
        docinfo                 = extern
        mlock                   = 0
        morphology              = stem_en
        min_word_len            = 2
        charset_type            = sbcs
        ignore_chars            = U+00AD
        phrase_boundary         = ., ?, !, U+2026 # horizontal ellipsis
        html_strip              = 0
        preopen                 = 1
}

Can anyone please tell me what I am doing wrong?

I removed sensitive data from the code.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

回忆躺在深渊里 2024-09-24 22:19:09

您能否尝试从命令行运行这些命令:

search -i indexTubelogr myterm
search -i indexTubelogr -f item_site_1 1 myterm

并比较输出?

Could you please try running these commands from the command line:

search -i indexTubelogr myterm
search -i indexTubelogr -f item_site_1 1 myterm

and compare the outputs?

守护在此方 2024-09-24 22:19:09

好吧我最后发现了问题。我忘记在 sphinx.conf 文件中设置 item_site_id 的属性。

然后用 $cl->SetFilter('item_site_id', array(1));我拉出了结果。

感谢您提供的所有信息!

Ok I found the problem in the end. I forgot to set the attribute for item_site_id in the sphinx.conf file.

Then with $cl->SetFilter('item_site_id', array(1)); i pulled the results.

Thanks for all the info!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文