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>
<div class="aritcle_card">
<a class="aritcle_card_img" href="/ai/1104">
<img src="https://img.php.cn/upload/ai_manual/001/503/042/68b6c5d39a38c971.png" alt="阿里云-虚拟数字人">
</a>
<div class="aritcle_card_info">
<a href="/ai/1104">阿里云-虚拟数字人</a>
<p>阿里云-虚拟数字人是什么? ...</p>
<div class="">
<img src="/static/images/card_xiazai.png" alt="阿里云-虚拟数字人">
<span>2</span>
</div>
</div>
<a href="/ai/1104" class="aritcle_card_btn">
<span>查看详情</span>
<img src="/static/images/cardxiayige-3.png" alt="阿里云-虚拟数字人">
</a>
</div>
<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>
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号