本文整理汇总了PHP中SphinxClient::ResetGroupBy方法的典型用法代码示例。如果您正苦于以下问题:PHP SphinxClient::ResetGroupBy方法的具体用法?PHP SphinxClient::ResetGroupBy怎么用?PHP SphinxClient::ResetGroupBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SphinxClient
的用法示例。
在下文中一共展示了SphinxClient::ResetGroupBy方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: resetClient
protected function resetClient()
{
$this->sphinxClient->ResetFilters();
$this->sphinxClient->ResetGroupBy();
$this->sphinxClient->ResetOverrides();
$this->sphinxClient->SetLimits(0, 20);
$this->sphinxClient->SetArrayResult(true);
$this->sphinxClient->SetFieldWeights(array());
$this->sphinxClient->SetIDRange(0, 0);
$this->sphinxClient->SetIndexWeights(array());
$this->sphinxClient->SetMatchMode(SPH_MATCH_EXTENDED2);
$this->sphinxClient->SetRankingMode(SPH_RANK_NONE);
$this->sphinxClient->SetSortMode(SPH_SORT_RELEVANCE, "");
$this->sphinxClient->SetSelect("*");
}
示例2: fopen
$file = fopen("spec/fixtures/data/phrase.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("testing this ")]);
fclose($file);
$client->SetMatchMode(SPH_MATCH_ALL);
// filter
$client->SetFilter("id", array(10, 100, 1000));
$file = fopen("spec/fixtures/data/filter.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->ResetFilters();
// group
$client->SetGroupBy("id", SPH_GROUPBY_ATTR, "id");
$file = fopen("spec/fixtures/data/group.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->ResetGroupBy();
// distinct
$client->SetGroupDistinct("id");
$file = fopen("spec/fixtures/data/distinct.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->ResetGroupBy();
// weights
$client->SetWeights(array(100, 1));
$file = fopen("spec/fixtures/data/weights.bin", "w");
fwrite($file, $client->_reqs[$client->AddQuery("test ")]);
fclose($file);
$client->SetWeights(array());
// anchor
$client->SetGeoAnchor("latitude", "longitude", 10.0, 95.0);
$file = fopen("spec/fixtures/data/anchor.bin", "w");
示例3: resetSphinx
private function resetSphinx()
{
$this->sphinx->ResetGroupBy();
$this->sphinx->ResetFilters();
return $this;
}
示例4: resetgroup
function resetgroup()
{
$this->sphinx->ResetGroupBy();
}
示例5: search
//.........这里部分代码省略.........
}
$cl->SetFilter('series_attr', $facet_args['facet_series']);
}
// Filter by Language
if (count($facet_args['facet_lang'])) {
foreach ($facet_args['facet_lang'] as &$facet_lang) {
$facet_lang = $this->string_poly($facet_lang);
}
$cl->SetFilter('lang', $facet_args['facet_lang']);
}
// Filter inactive records
if (!$show_inactive) {
$cl->SetFilter('active', array('0'), TRUE);
}
// Filter by age
if (count($facet_args['age'])) {
foreach ($facet_args['age'] as $age_facet) {
$cl->SetFilter('ages', array($this->string_poly($age_facet)));
}
}
// Filter by availability
if ($limit_available) {
$cl->SetFilter('branches', array($this->string_poly($limit_available)));
}
$cl->SetRankingMode(SPH_RANK_SPH04);
$proximity_check = $cl->Query($term, $idx);
// Quick check on number of results
// If original match didn't return any results, try a proximity search
if (empty($proximity_check['matches']) && $bool == FALSE && $term != "*" && $type != "tags") {
$term = '"' . $term . '"/1';
$cl->SetMatchMode(SPH_MATCH_EXTENDED);
$forcedchange = 'yes';
}
// Paging/browsing through the result set.
$sort_limit = 2000;
if ($offset + $limit > $sort_limit) {
$sort_limit = $offset + $limit;
}
$cl->SetLimits((int) $offset, (int) $limit, (int) $sort_limit);
// And finally.... we search.
$cl->AddQuery($term, $idx);
// CREATE FACETS
$cl->SetLimits(0, 1000);
// Up to 1000 facets
$cl->SetArrayResult(TRUE);
// Allow duplicate documents in result, for facet grouping
$cl->SetGroupBy('pub_year', SPH_GROUPBY_ATTR);
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('pub_decade', SPH_GROUPBY_ATTR);
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('mat_code', SPH_GROUPBY_ATTR, '@count desc');
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('branches', SPH_GROUPBY_ATTR, '@count desc');
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('ages', SPH_GROUPBY_ATTR, '@count desc');
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('lang', SPH_GROUPBY_ATTR, '@count desc');
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('series_attr', SPH_GROUPBY_ATTR, '@count desc');
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$cl->SetGroupBy('lexile', SPH_GROUPBY_ATTR);
$cl->AddQuery($term, $idx);
$cl->ResetGroupBy();
$results = $cl->RunQueries();
// Include descriptors
$final_result_set['num_hits'] = $results[0]['total_found'];
if ($results[0]['total'] <= $this->locum_config['api_config']['suggestion_threshold'] || $forcedchange == 'yes') {
if ($this->locum_config['api_config']['use_yahoo_suggest'] == TRUE) {
$final_result_set['suggestion'] = $this->yahoo_suggest($term_prestrip);
}
}
// Pull full records out of Couch
if ($final_result_set['num_hits']) {
$skip_avail = $this->csv_parser($this->locum_config['format_special']['skip_avail']);
$bib_hits = array();
foreach ($results[0]['matches'] as $match) {
$bib_hits[] = (string) $match['id'];
}
$final_result_set['results'] = $this->get_bib_items_arr($bib_hits);
foreach ($final_result_set['results'] as &$result) {
$result = $result['value'];
if ($result['bnum']) {
// Get availability (Only cached)
$result['status'] = $this->get_item_status($result['bnum'], FALSE, TRUE);
}
}
}
$final_result_set['facets'] = $this->sphinx_facetizer($results);
if ($forcedchange == 'yes') {
$final_result_set['changed'] = 'yes';
}
return $final_result_set;
}
示例6: dataFromSphinx
/**
* 从sphinx获取数据
* @author 吕小虎
* @datetime
* @return
*/
public function dataFromSphinx($data)
{
$this->data = $data;
//分词
$this->data['split'] = \Xz\Func\Common\Tools::curlGetContentMs($this->di['config']->base->split . '/wd/' . urlencode($this->data['wd']), 50);
if (empty($this->data['split'])) {
$this->data['split'] = $data['wd'];
}
$sphinxConfig = $this->di["config"]["combusinessearchsphinxdist"];
$sphinx = new \SphinxClient();
$sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
// $sphinx->SetServer('172.17.17.103', 9111);
$indexTable = $sphinxConfig->table;
$gcdweight = "weight()+IF(hasgccid>0, 1000, 0) as cbweight";
$fieldStr = "id, comname, legal, areaid, uptime,{$gcdweight}";
$sphinx->SetSelect($fieldStr);
//排序 有gccid的靠前
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'cbweight DESC');
//搜某个字段
$t = isset($this->data['t']) ? trim($this->data['t']) : '';
//搜索类型 app/common
$type = isset($this->data['type']) ? $this->data['type'] : 'common';
//一级分类筛选
if (!empty($this->data['cate1id']) && intval($this->data['cate1id']) > 0) {
// $sphinx->AddQuery('@cate1 ' . $this->data['cate1id'], $indexTable);
$sphinx->SetFilter('cate1', array(intval($this->data['cate1id'])), false);
}
//二级分类筛选
if (!empty($this->data['cate2id']) && intval($this->data['cate2id']) > 0) {
// $sphinx->AddQuery('@cate2 ' . $this->data['cate2id'], $indexTable);
$sphinx->SetFilter('cate2', array(intval($this->data['cate2id'])), false);
}
//地区筛选
if (!empty($this->data['areaid']) && intval($this->data['areaid']) > 0) {
if ($this->data['areaid'] % 10000 == 0) {
$start = intval($this->data['areaid'] / 10000) * 10000;
$end = $start + 9999;
$sphinx->SetFilterRange('areaid', $start, $end, false);
} elseif ($this->data['areaid'] % 100 == 0) {
$start = intval($this->data['areaid'] / 100) * 100;
$end = $start + 99;
$sphinx->SetFilterRange('areaid', $start, $end, false);
} else {
$sphinx->SetFilter('areaid', array(intval($this->data['areaid'])));
}
}
$offset = isset($this->data['offset']) ? intval($this->data['offset']) : 0;
$limit = isset($this->data['limit']) ? intval($this->data['limit']) : 200;
$max = isset($this->data['max']) ? intval($this->data['max']) : 200;
$sphinx->SetLimits($offset, $limit, $max);
$keyStr = '';
//企业名称和企业法人搜索 企业注册号搜索
if (!empty($this->data['wd'])) {
//加快搜索速度
$replace = array('省', '市', '区', '县', '乡', '镇', '有限公司');
$this->data['split'] = str_replace($replace, '', $this->data['split']);
//处理搜索词 提高搜索精度
$keyArr = explode(' ', $this->data['split']);
$keyArr = array_filter($keyArr);
if (is_array($keyArr) && !empty($keyArr)) {
foreach ($keyArr as $value) {
$keyStr .= '"' . $value . '" ';
}
}
if (is_numeric($this->data['wd']) && mb_strlen($this->data['wd'], 'UTF-8') == 15) {
//注册号全匹配搜索
$sphinx->AddQuery('@regno ' . $this->data['wd'], $indexTable);
} elseif ($t == 'legal') {
//企业名称和法人搜索
$sphinx->AddQuery('@legal ' . $this->data['wd'], $indexTable);
} else {
//企业名称和法人搜索
$sphinx->AddQuery('@(comname,legal) ' . $keyStr, $indexTable);
}
}
//cate1
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('cate1', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
$sphinx->AddQuery('@(comname,legal)' . $keyStr, $indexTable);
//cate2
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('cate2', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
$sphinx->AddQuery('@(comname,legal)' . $keyStr, $indexTable);
//areaid
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('areaid', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
$sphinx->AddQuery('@(comname,legal)' . $keyStr, $indexTable);
$result = array();
$batchResult = $sphinx->RunQueries();
$error = $sphinx->getLastError();
if ($error) {
//.........这里部分代码省略.........
示例7: fromSpecialSphinx
/**
* 特殊的搜索,用于供应商查询收录,产品查询收录等
*
* @Author tianyunzi
* @DateTime 2015-12-23T15:16:46+0800
* @param [type] $data [description]
* @return [type] [description]
*/
public function fromSpecialSphinx($data)
{
$this->data = $data;
$this->data["split"] = "@comname " . $this->data["wd"];
$sphinxConfig = $this->di["config"]["prosearchd"];
$sphinx = new \SphinxClient();
$sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
//$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2);
$indexTable = "product_distri";
//TODO 索引范围
if (isset($this->data["cate1"]) && $this->data["cate1"] > 0) {
$indexTable = "product_distri_" . $this->data["cate1"];
}
if (!isset($this->data['cateid']) && isset($this->data['cate3'])) {
$this->data['cateid'] = $this->data['cate3'];
}
$sphinx->SetSelect("id, cid, brand, feature, province, city");
if (isset($this->data["pid"]) && $this->data["pid"] > 0) {
$this->data["split"] = "";
$sphinx->SetFilter("id", array($this->data["pid"]), false);
}
if (isset($this->data["cid"]) && $this->data["cid"] > 0) {
$this->data["split"] = "";
$sphinx->SetFilter("cid", array($this->data["cid"]), false);
}
if (!empty($this->data['cateid']) && intval($this->data['cateid']) > 0) {
$sphinx->SetFilter('cate3', array(intval($this->data['cateid'])), false);
}
if (!empty($this->data['brand']) && intval($this->data['brand']) > 0) {
$sphinx->SetFilter('brand', array(intval($this->data['brand'])), false);
}
if (!empty($this->data['province']) && intval($this->data['province']) > 0) {
$sphinx->SetFilter('province', array(intval($this->data['province'])), false);
}
if (!empty($this->data['city']) && intval($this->data['city']) > 0) {
$sphinx->SetFilter('city', array(intval($this->data['city'])), false);
}
if (!empty($this->data['iscertify']) && intval($this->data['iscertify']) > 0) {
$sphinx->SetFilter('is_gccertify', array(intval($this->data['iscertify'])), false);
}
if (!empty($this->data['isprice']) && intval($this->data['isprice']) > 0) {
$sphinx->SetFilterRange('price', 1, 9999999, false);
}
if (!empty($this->data['feature'])) {
$featureArr = explode('_', $this->data['feature']);
foreach ($featureArr as $value) {
$sphinx->SetFilter('feature', array(intval($value)), false);
}
}
if (!empty($this->data['sort'])) {
switch ($this->data['sort']) {
case 1:
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'tradenum DESC');
break;
case 2:
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'visitnum DESC');
//访问量/热度
break;
case 3:
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'price DESC');
break;
case 4:
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'price ASC');
break;
case 6:
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'integral DESC');
break;
default:
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'id DESC');
break;
}
} else {
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'id DESC');
}
if (isset($this->data['pid']) && $this->data['pid'] > 0) {
$sphinx->SetLimits(0, 1, 1);
} else {
$sphinx->SetLimits(0, 200, 200);
}
$sphinx->AddQuery($this->data['split'], $indexTable);
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('feature', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
$sphinx->AddQuery($this->data['split'], $indexTable);
$sphinx->ResetGroupBy();
if (isset($this->data["pid"]) && $this->data["pid"] > 0) {
$sphinx->SetLimits(0, 1, 1);
} else {
$sphinx->SetLimits(0, 20, 20);
}
$sphinx->SetGroupBy('brand', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->AddQuery($this->data['split'], $indexTable);
//.........这里部分代码省略.........
示例8: sphinxList
function sphinxList($filterArr, $page = 0)
{
$result = array('data' => array(), 'cate4' => array(), 'property' => array(), 'province' => array(), 'city' => array(), 'brand' => array(), 'total_found' => 0, 'time' => 0);
$perpage = isset($filterArr['perpage']) && $filterArr['perpage'] ? $filterArr['perpage'] : 20;
$sphinxConfig = array('host' => '172.17.17.105', 'port' => 9020);
$sphinx = new \SphinxClient();
$sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
if (isset($filterArr["has_children"]) && $filterArr["has_children"] == 1) {
$indexTable = "product_distri_special";
} elseif (isset($filterArr['cate1']) && $filterArr['cate1']) {
$indexTable = "product_distri_" . $filterArr["cate1"];
} else {
$indexTable = "product_m_distri";
}
$gcdweight = "weight()+IF(id>900000000, tradenum*100, 0)+inquirynum*20+star*2+basescore*5+creditscore+IF(is_op=1, all_uv*10+all_pv, 0)+IF(id>900000000, weight()*0.1, 0) as gcpdweight";
if (isset($filterArr["has_children"]) && $filterArr["has_children"] == 1) {
$sphinx->SetSelect("id, cid, brand, cate4, feature, province, city, {$gcdweight}");
} else {
$sphinx->SetSelect("id, cid, brand, feature, province, city, {$gcdweight}");
}
/**************************************** 过滤模块 ******************************************/
/* 分类过滤 */
if (isset($filterArr['cate3']) && isset($filterArr['cate2to3'])) {
$sphinx->SetFilter('cate2', array(intval($filterArr["cate3"])), false);
} elseif (isset($filterArr['cate3'])) {
$sphinx->SetFilter('cate3', array(intval($filterArr["cate3"])), false);
}
/* 是否通过工厂认证 */
if (isset($filterArr['filters']['iscertify']) && $filterArr['filters']['iscertify'] > 0) {
$sphinx->SetFilter('is_gccertify', array($filterArr['filters']['iscertify']), false);
}
/* 是否显示价格 */
if (isset($filterArr['filters']['isprice']) && $filterArr['filters']['isprice'] > 0) {
$sphinx->SetFilterRange('price', 1, 9999999, false);
}
/* 省过滤 */
if (!empty($filterArr['filters']['province']) && is_numeric($filterArr['filters']['province'])) {
$sphinx->SetFilter('province', array(intval($filterArr['filters']['province'])), false);
}
/* 市过滤 */
if (!empty($filterArr['filters']['city']) && is_numeric($filterArr['filters']['city'])) {
$sphinx->SetFilter('city', array(intval($filterArr['filters']['city'])), false);
}
/* 品牌过滤 */
if (isset($filterArr['filters']['brand']) && $filterArr['filters']['brand'] > 0) {
$sphinx->SetFilter('brand', array(intval($filterArr['filters']['brand'])), false);
}
/* 属性过滤 */
if (isset($filterArr['filters']['feature']) && $filterArr['filters']['feature']) {
$featureArr = explode('_', $filterArr['filters']['feature']);
foreach ($featureArr as $value) {
$sphinx->SetFilter('feature', array(intval($value)), false);
}
}
/***************************************** 过滤结束 ******************************************/
/***************************************** 排序 *********************************************/
$sort = isset($filterArr['orders']['sort']) ? $filterArr['orders']['sort'] : '';
if ($sort && $sort == 1) {
//销量倒叙排列
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'tradenum DESC');
} elseif ($sort && $sort == 2) {
//热度倒叙排列
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'visitnum DESC');
} elseif ($sort && $sort == 3) {
//价格正序排列
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'price ASC');
} elseif ($sort && $sort == 4) {
//价格倒序排列
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'price DESC');
} elseif ($sort && $sort == 5) {
//返积分正序排列
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'integral DESC');
} else {
//默认综合排序
$sphinx->SetSortMode(SPH_SORT_EXTENDED, 'gcpdweight DESC');
}
/*************************************** 排序结束 ********************************************/
/* limit限制 */
$sphinx->SetLimits(0, $perpage * 10, $perpage * 10);
$sphinx->AddQuery("", $indexTable);
/**************************************** 开始并发查询 **************************************/
/*############# 属性 ###############*/
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('feature', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 200, 200);
$sphinx->AddQuery("", $indexTable);
/*############# 省 ###############*/
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('province', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
$sphinx->AddQuery("", $indexTable);
/*############# 市 ###############*/
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('city', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
$sphinx->AddQuery("", $indexTable);
/*############# 品牌 ###############*/
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('brand', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->SetLimits(0, 20, 20);
//.........这里部分代码省略.........
示例9: dataFilterFromSphinx
/**
* 功能描述 获取筛选
* @author 吕小虎
* @datetime ${DATE} ${TIME}
* @version
* @param
* @return
*/
public function dataFilterFromSphinx($data)
{
$this->data = $data;
//分词
$this->data['split'] = \Xz\Func\Common\Tools::curlGetContentMs($this->di['config']->base->split . '/wd/' . urlencode($this->data['wd']), 50);
if (empty($this->data['split'])) {
$this->data['split'] = $data['wd'];
}
$sphinxConfig = $this->di["config"]["combusinessearchsphinxdist"];
$sphinx = new \SphinxClient();
$sphinx->SetServer($sphinxConfig['host'], intval($sphinxConfig['port']));
$indexTable = $sphinxConfig->table;
$fieldStr = isset($data['field']) ? implode(',', $data['field']) : "id, comname, legal, areaid, uptime";
$sphinx->SetSelect($fieldStr);
//一级分类筛选
if (!empty($this->data['cate1id']) && intval($this->data['cate1id']) > 0) {
$sphinx->AddQuery('@cate1', $this->data['cate1id'], $indexTable);
}
//二级分类筛选
if (!empty($this->data['cate2id']) && intval($this->data['cate2id']) > 0) {
$sphinx->AddQuery('@cate2', $this->data['cate2id'], $indexTable);
}
//地区筛选
if (!empty($this->data['areaid']) && intval($this->data['areaid']) > 0) {
if ($this->data['areaid'] % 10000 == 0) {
$start = intval($this->data['areaid'] / 10000) * 10000;
$end = $start + 9999;
$sphinx->SetFilterRange('areaid', $start, $end, false);
} elseif ($this->data['areaid'] % 100 == 0) {
$start = intval($this->data['areaid'] / 100) * 100;
$end = $start + 99;
$sphinx->SetFilterRange('areaid', $start, $end, false);
} else {
$sphinx->SetFilter('areaid', intval($this->data['areaid']));
}
}
//企业名称和法人搜索
$sphinx->SetLimits(0, 1, 1);
$sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
$sphinx->ResetGroupBy();
//分类
$sphinx->SetLimits(0, 20, 20);
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('cate1', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
$sphinx->SetLimits(0, 20, 20);
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('cate2', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
//地区
$sphinx->SetLimits(0, 35, 20);
$sphinx->ResetGroupBy();
$sphinx->SetGroupBy('areaid', SPH_GROUPBY_ATTR, "@count desc");
$sphinx->AddQuery('@(comname,legal)' . $this->data['split'], $indexTable);
$result = array();
$batchResult = $sphinx->RunQueries();
// print_r($batchResult);
$error = $sphinx->getLastError();
if ($error) {
$result = array('cate1' => array(), 'cate2' => array(), 'areaid' => array());
} else {
// $result['data'] = $batchResult[0];
$result['cate1'] = array();
if (isset($batchResult[1]['matches']) && is_array($batchResult[1]['matches']) && !empty($batchResult[1]['matches'])) {
foreach ($batchResult[1]['matches'] as $value) {
$result['cate1'][$value['attrs']['@groupby']] = $value['attrs']['@count'];
}
}
$result['cate2'] = array();
if (isset($batchResult[2]['matches']) && is_array($batchResult[2]['matches']) && !empty($batchResult[2]['matches'])) {
foreach ($batchResult[2]['matches'] as $value) {
$result['cate2'][$value['attrs']['@groupby']] = $value['attrs']['@count'];
}
}
$result['areaid'] = array();
if (isset($batchResult[3]['matches']) && is_array($batchResult[3]['matches']) && !empty($batchResult[3]['matches'])) {
foreach ($batchResult[3]['matches'] as $value) {
$result['areaid'][$value['attrs']['@groupby']] = $value['attrs']['@count'];
}
}
}
return $result;
}
示例10: resetGroup
/**
* reset group condition
* 重置分组条件
*/
public function resetGroup()
{
parent::ResetGroupBy();
}