当前位置: 技术问答>linux和unix
coreseek里not in 和 关键词为空怎么处理?
来源: 互联网 发布时间:2017-04-08
本文导语: linux下coreseek服务已经搭建好, 使用php接口调用 require WEIBO_ROOT . 'source/class/class_sphinx.php' ; $cl = new SphinxClient (); $sphinx = getglobal('config/sphinx' ); $cl->SetServer ( $sphinx ['host' ], ...
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 '
使用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 '
';
//print_r($cl);
print_r($res);exit;
我要加个cid not in (5,6)这样的条件该怎么加,
还有关键词为空时怎么出结果?
|
cid not in (5,6)写成:
$cl->SetFilter ( "tid", array (5,6), true);
默认关键次为空是是没有结果的,如果要展现所有信息,需要修改匹配模式为SPH_MATCH_FULLSCAN
$cl->setMatchMode(SPH_MATCH_FULLSCAN);
$cl->SetFilter ( "tid", array (5,6), true);
默认关键次为空是是没有结果的,如果要展现所有信息,需要修改匹配模式为SPH_MATCH_FULLSCAN
$cl->setMatchMode(SPH_MATCH_FULLSCAN);
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。