douhao2856 2010-09-05 08:45
浏览 149
已采纳

Sphinx setFilter()会杀死所有结果

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.

  • 写回答

2条回答 默认 最新

  • dongzhuang2030 2010-09-05 10:53
    关注

    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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab图像高斯低通滤波
  • ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
  • ¥15 钢筋实图交点识别,机器视觉代码
  • ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
  • ¥50 400g qsfp 光模块iphy方案
  • ¥15 两块ADC0804用proteus仿真时,出现异常
  • ¥15 关于风控系统,如何去选择
  • ¥15 这款软件是什么?需要能满足我的需求
  • ¥15 SpringSecurityOauth2登陆前后request不一致
  • ¥15 禅道二次开发编辑版本,上传不了发行包