Heim  >  Artikel  >  Backend-Entwicklung  >  coreseek里not in 和 关键词为空怎么处理?

coreseek里not in 和 关键词为空怎么处理?

WBOY
WBOYOriginal
2016-06-23 14:06:041333Durchsuche

linux下coreseek服务已经搭建好,

使用php接口调用
require WEIBO_ROOT . 'source/class/class_sphinx.php' ;
        $cl = new SphinxClient ();
        $sphinx = getglobal('config/sphinx' );
        $cl->SetServer ( $sphinx ['host' ], $sphinx ['port' ]);
        $cl->setMatchMode(SPH_MATCH_ANY);
        $cl->setLimits(0, 5);
        $cl->SetFilter ( "tid", array (68, 69));
        $cl->SetFilter ( "status", array (0));
        $cl->SetFilter ( "top_status", array (2));
        $cl->setFilterRange('pubtime', 0, $_G['timestamp']);
        $cl->SetSortMode ( SPH_SORT_ATTR_DESC, "top_status" );
        $cl->SetSortMode ( SPH_SORT_ATTR_ASC, "totalnum" );
        $res = $cl ->Query ( '我', "library" );
        if (isset ($res ['matches' ])) {
            $cid_arr = array_keys($res ['matches' ]);
            $cids = implode(',' , $cid_arr );
        }
        echo '

';  <br>         //print_r($cl);  <br>          <br>         print_r($res);exit;  <br>  <br> 我要加个cid not in (5,6)这样的条件该怎么加,  <br>  <br> 还有关键词为空时怎么出结果?  <p>  </p>  <br> <h2>回复讨论(解决方案)</h2> <p class="sougouAnswer">  cid not in (5,6)写成:  <br>  $cl->SetFilter ( "tid", array (5,6), true);  <br>    <br> 默认关键次为空是是没有结果的,如果要展现所有信息,需要修改匹配模式为SPH_MATCH_FULLSCAN  <br>  $cl->setMatchMode(SPH_MATCH_FULLSCAN); </p>
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn