1. 阿里云>
  2. 云栖社区>
  3. 正文

php连接coreseek






<?php
include_once 'sphinxapi.php';
$s = new SphinxClient();
$s->setServer("localhost", 9312);
$s->SetConnectTimeout ( 1 );//设置链接超时
$s->setMatchMode(SPH_MATCH_ANY);//匹配模式
$s->setMaxQueryTime(3);//查询超时
//$s->SetSelect ( $select );//设置返回的字段
/*
$cl->SetSelect ("*, @weight+(user_karma+ln(pageviews))*0.1 AS myweight");
$cl->SetSelect ("exp_years, salary_gbp*{$gbp_usd_rate} AS salary_usd,
IF(age>40,1,0) AS over40");
$cl->SetSelect ("*, AVG(price) AS avgprice");
*/
/*
$cl->SetGroupBy ("category", SPH_GROUPBY_ATTR,"@count desc");
$cl->SetGroupDistinct ("vendor");
==
SELECT id, weight, all-attributes,
COUNT(DISTINCT vendor) AS @distinct,
COUNT(*) AS @count
FROM products
GROUP BY category
ORDER BY @count DESC
*/
//$s->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );//汇总
//$s->SetGroupDistinct ( $distinct );//设置不重复字段
$s->SetArrayResult ( true );//结果是否有ID//$s->SetSortMode ( SPH_SORT_EXTENDED, $sortby );//排序模式//link
//$s->SetFilter ( 'target_type', array(1),true );$s->SetLimits ( 0, 10 );//显示数量:开始 量 最大量 右偏移量
$result = $s->query("good","team");//查询print_r($result);
 

相关文章

立即打开APP,浏览更多精彩内容