解决xunsearch热门搜索,不按照数量排序问题
2024-08-29 06:36:40
public function getHotQuery($limit = 6, $type = 'total')
{
$ret = array();
$limit = max(1, min(50, intval($limit)));
$this->xs->setScheme(XSFieldScheme::logger());
try {
$this->setDb(self::LOG_DB)->setLimit($limit);
if ($type !== 'lastnum' && $type !== 'currnum') {
$type = 'total';
}
// 加上下面这一句就OK了
$this->setSort('total');
$result = $this->search($type . ':1');
foreach ($result as $doc) /* @var $doc XSDocument */ {
$body = $doc->body;
$ret[$body] = $doc->f($type);
}
$this->restoreDb();
} catch (XSException $e) {
if ($e->getCode() != XS_CMD_ERR_XAPIAN) {
throw $e;
}
}
$this->xs->restoreScheme();
return $ret;
}
$this->setSort('total');
不正确的
{
"errno": 0,
"errdesc": "操作成功",
"timestamp": 1576057980,
"data": {
"项目测试": "2",
"俗话说": "1",
"测试": "12",
"项目": "1"
}
}
正确的
{
"errno": 0,
"errdesc": "操作成功",
"timestamp": 1576057928,
"data": {
"测试": "12",
"项目测试": "2",
"俗话说": "1",
"项目": "1"
}
}
最新文章
- [转]Python yield 使用浅析
- webbrowser 禁用 alert
- Mac中体验ASP.NET 5 beta2的K gen代码生成
- 获取ItemsControl中当前item的binding数据
- dubbo通信协议之对比
- no.1
- Fusioncharts使用说明
- 掌握iOS自动布局
- Transaction的理解
- CF 295E Yaroslav and Points(Splay)
- collapse
- .net 常用方法
- POJ 3691 &;amp; HDU 2457 DNA repair (AC自己主动机,DP)
- iOS 打包上传AppStore相关(2)-Xcode相应配置
- Chapter 2 Open Book——6
- 为什么阿里巴巴禁止在 foreach 循环里进行元素的 remove/add 操作--java.util.ConcurrentModificationException
- python3 cookie
- [转帖] cnblog新闻区 “40岁以上的员工,请自觉离开”
- Linux下的定时器类实现(select定时+线程)
- js模块化的两种规范AMD和CMD
热门文章
- MySql数据库中正则表达式
- 设计模式之(十)装饰模式(DECORATOR)
- [git] your branch is ahead of ... 解决办法
- Telegram Android源码问题汇总 持续更新
- Python环境安装与基础语法(4)——内存管理、if分支
- 非root用户安装、配置mysql
- 青春正盛,未来可期。马上2020了,低成本投资自己:vip测试提升圈
- Lp距离, L1范数, 和L2范数(转载)
- Mysql基础知识--视图
- LeetCode3-Longest_Substring_Without_Repeating_Characters